<- back

# Docker for the Impatient, Explained inadequately

Posted on Dec 31, 2025

Docker is used to run application in isolated environments called containers. This helps solve the 'it works on my machine' problem as docker puts apps into containers that are packaged with code, dependencies, system variables and tools. Each app has its own container so dependencies don't conflict between applications.

## The Docker File

Each project contains a docker file which includes the instructions on building the image for the app. Here is an example docker file which would be named: Dockerfile

FROM python:3.8
WORKDIR /app
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]

- What this file means:

FROM python:3.8

This gets the base image which contains a linux os and python 3.8 installed, everything after this instruction builds on top of it

WORKDIR /app

This is the working directory inside the image, if it dosen't exist docker will create it.

RUN pip install -r requirements.txt

We use this to install all the dependencies required.

COPY . .

This copies the application code into the image after the dependencies are installed.

CMD ["python", "app.py"]

This defines the default command executed at runtime, for us it would be running the app.

## Docker Image

When we run the command docker build -t app . it tells the docker engine to build an image and assign the image a tag in the current directory. The image is stored locally on the machine in dockers image store which is managed by the docker engine.

The image contains the filesystem, system libraries, installed dependencies and application source code. It does not include logs or dynamically generated data.

## Docker Container

Next, the docker run tag command is used to create and start containers from the image. This sets up the containers filesystem and executes the image's command CMD

You can even map ports to containers, name them or override the default commands

  • docker run -p 8000:8000 my-python-app
  • docker run --name my-container my-python-app
  • docker run my-python-app python other.py
  • ## How I use docker for my portfolio site

    I built my docker image locally for my portfolio then pushed the image to the artifact registry and configured Cloud Run to run the image and serve it when http requests hit my service

    Cloud run is able to scale one image to multiple container instances which are all isolated from one another and requests are load balanced automatically, instances can start and stop at any time

    Kubernetes automates deploying, scalinf and managing containers, however that is beyond the scope of this article.

    ## Further reading

    From Dockerfile to Deployment: Navigating Docker's Build, Ship, and Run Cycle - Teodor Wisniewski May 21