Docker Fundamentals
2025-Oct-21
When I started programming, I thought that all I had to do was program. But as time passed, I figured out that there was much more to it. I needed to not only understand programming but also design, DevOps, and have a general knowledge of computers. So, I dug into some of these topics but skipped what I found boring: DevOps. Yet now, after years, I have pulled through and come to understand the fundamentals of some topics in DevOps, one being Docker. Learning Docker was like bringing my software development knowledge to a completely different level. So, I would like to share what exactly it is in short, so you may have an easier time understanding it and its use cases.
Summary of Docker
Dockers' main purpose is to make life easier for developers. We all work on different computers, thus also different environments. Some use the newest version of Python, while others use an older version. Different environments make it hard for developers to collaborate because some methodologies, syntax, and features differ from one to another. To address this problem, Docker is a solution. In short, with Docker, you can run a containerized environment, which means you can run your application with a set environment; instead of just running the application, you now run the environment and the application.
To understand Docker, you have to understand the tree underlying parts that makes up Docker. Those three parts are Dockerfiles, images and containers.
Dockerfiles
With Dockerfiles, you specify the configuration of the environment and the steps to run your application in that environment. To create one of these files, you need to make a Dockerfile in your repository. After that, you edit this file and add steps such as the base image, working directory, and environment variables. An example of a Dockerfile is shown below to visualize what I mean by editing the file.
FROM node:18-alpine as builder
WORKDIR /app
COPY package*.json ./
RUN npm install && npm cache clean --force
COPY . .
EXPOSE 3000
CMD npm run build
Docker images
Once you have configured the Dockerfile, you can now go ahead and create your first Docker image. A Docker image is a snapshot of a file system that forms the basis of a container. It is like packaging the environment specified in the Dockerfile with the application you have made. The most typical way of creating a Docker image is with the Docker command docker build -t . An example of creating an image is docker build -t my-app:latest ., and you can ensure that you have created a Docker image by running the following command: docker image ls.
Docker containers
Now that you have created the image, you can run it as a container. A container is the package, meaning the image, almost like a kind of software by itself. You can create multiple containers from the same image, and you can always close them down if you wish to stop running that specific container. For example, if you have created an image called my-app, you can run this image as a container by executing the command: docker run --name container-of-my-app my-app. Now you have a container called container-of-my-app that runs the my-app image.
If you'd like to know more about it, I have linked to many documents and videos below. Also, I suggest you try to create your first Dockerfile, image, and container, because it will help you get into the workflow. Lastly, I will also soon be making an educational video that I hope will help you with using the fundamentals I just wrote about.
Docker 101 Tutorial The Only Docker Tutorial You Need To Get Started Docker in 100 Seconds What’s the Difference Between Docker Images and Containers? Writing a Dockerfile