docker.png

One of the greatest nightmares of developers is the “It's not working on my machine” problem. I struggled to run my website locally on different machines too. Shout out to Brittany Mitchell for giving me the idea to containerize my website. Containerization allowed me to build my website and run it consistently across different environments and machines. Docker is the tool for achieving this containerization.

Image Source: r/ProgrammerHummor

Image Source: r/ProgrammerHummor

What is Docker?

Docker is an open-source platform for developing, shipping, and running applications. It is a technology that allows you to incorporate and store your code and its dependencies into a neat little package called an image.

Dockerfile, Docker Image, and Docker Container

Dockerfile:

A Dockerfile is a text file containing a collection of commands or procedures. Consider this file as a script that defines how our container image will be built.

Docker Image:

A docker image is a packaged, runnable instance of an application or environment. It contains everything needed to run a piece of software (or website in our case), including the code, a runtime, libraries, environment variables, and configuration files. A docker image is read-only template for creating containers.

Docker Container:

A docker container is a lightweight, stand-alone, executable package of software that includes everything needed to run the software. Containers isolate applications from each other and the underlying infrastructure while providing an added layer of protection for the application. Containerization solves the problem related to application deployment, and scalability. It helps promote consistency and efficiency in software development and operations.

https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w5vjiak4eaeaw5gjtqg5.jpeg


Here is how I containerized my website

As a prerequisite, ensure that you have docker installed locally on your machine. Install Docker Engine

The code for my website is hosted on GitHub. To follow along, fork and clone this repository and change directory into it by running the commands below:

git clone <https://github.com/paschalogu/personal-website.git>
cd personal-website

Step 1: Build the Docker image