A container image packages a filesystem, application code, dependencies, and configuration into a reusable artifact. Docker creates a container instance from that image; the instance runs the image’s process and can be stopped or recreated. section 2.1.2 section 2.4
Build an image when an application must run consistently across machines. A Dockerfile records procedural build instructions: choose a base image, install the required language and operating-system dependencies, copy the application, select its working directory, and define its command. section 2.1.3 section 2.1.6
The practical image workflow is:
- Start from a suitable base image, such as Ubuntu or a Python image. section 2.1.2 section 2.1.6
- Install dependencies during the build, including language packages, database clients, fonts, or TLS certificates. section 2.1.6
- Copy application files into the image and build it with Docker. section 2.1.3
- Run the resulting image to create an ephemeral container instance; local Docker users can restart stopped instances or remove unused artifacts. section 2.1.2
A repeatable Python image
A Dockerfile can use Ubuntu, install Python, copy a small application into /app, and set that directory as the working directory. Building it as hello and running `docker run hello python3 hello.py` produces `Hello Docker` without installing Python on the local system. section 2.1.3
Listing 2.2 Chapter02/2.1.3_Dockerfile/Dockerfile
FROM ubuntu #1 RUN apt-get update #2 RUN apt-get install -y python3 #2 COPY . /app #3 WORKDIR /app #4
Inspect the Dockerfile that turns a base operating system, Python installation, and application files into an image. section 2.1.3
























