A container is an isolated, portable environment for running an application with its dependencies. Instead of installing each application’s runtime and supporting software on a production virtual machine, you can package those requirements with the application. The machine then needs a container runtime, such as Docker Engine, to run it. section 1.4 section 7.0
Start with a Dockerfile: it declares how to assemble a container image. A builder follows those instructions to bundle the application. A registry, such as Docker Hub, stores the image for distribution; a container runtime runs it. The instructions vary by application, but the build-and-run pattern stays much the same. section 1.4 section 5.6
Listing 1.1 Dockerfile
FROM python:3.10
COPY . /app
WORKDIR /app
RUN python3 -m pip install pip --upgrade && \
python3 -m pip install --no-cache-dir -r requirements.txt
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "main:app"]
This Python Dockerfile starts from a Python image, copies the application, installs its requirements, and declares the command to run the web app. section 1.4
A shell is not a lasting installation
Run an Ubuntu container with `docker run --rm -it ubuntu /bin/bash`, then install NGINX inside it. After you exit, `--rm` removes that container; starting again does not preserve the installation. Put repeatable installation steps in a Dockerfile rather than relying on changes made in an interactive shell. A container has its own shell and file system, but it is designed to be replaceable. section 5.1.3 section 5.1.4
Once an image is built, common deployment tasks are:
- Run an image with `docker run nginx`; add `-d` to keep NGINX running in the background. Use `docker ps` to find running containers and `docker logs` or `docker stop` to inspect or stop one. section 7.1.4
- Build and tag an application image in GitHub Actions, then push it to Docker Hub so a production machine can obtain it. section 7.3.1
Containers simplify packaging, not every part of operations. Updating versions, scaling workloads, recovering from failures, and connecting multiple containers become difficult to manage manually. Kubernetes addresses these jobs by running containers across a cluster: a Deployment specifies an image and replica count through Pods, while a Service exposes the Pods. Stateful applications such as databases add storage and recovery concerns. section 1.5 section 8.1.3 section 1.6


























