Docker packages applications and their dependencies into containers — portable, reproducible units that run the same way on any machine. Understanding Docker is now a foundational skill for software development, regardless of specialisation.
Why Docker Matters
The “it works on my machine” problem is solved by Docker. A Docker container includes the application, its runtime, libraries, environment variables, and configuration — everything needed to run. The developer machine, the CI/CD pipeline, and the production server all run the same container image. Differences in OS, installed software, and system configuration disappear.
Core Concepts
Image: a read-only template (think: blueprint) built from a Dockerfile. Container: a running instance of an image (think: the building built from the blueprint). Dockerfile: a text file with instructions for building an image. Docker Hub: a registry of public images (nginx, postgres, python, node are all available as base images). docker-compose: a tool for defining multi-container applications in a YAML file.
Your First Container
Install Docker Desktop (Mac/Windows) or Docker Engine (Linux). Run: docker run -d -p 8080:80 nginx. This pulls the official nginx image, starts a container, and maps port 80 inside the container to port 8080 on your machine. Open localhost:8080 in your browser — you will see the nginx welcome page. You ran a web server in seconds without installing nginx locally.
Building Your Own Image
Create a Dockerfile in your project directory:
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]
Run docker build -t my-app . to build it. Run docker run -p 5000:5000 my-app to start it. Your Python app runs in a container with all dependencies included.
docker-compose for Multiple Services
Most applications need a database alongside the app. docker-compose.yml defines both services. docker compose up starts all services together; docker compose down stops them. This replaces the need to install PostgreSQL, Redis, or any other service on your local machine.




