An application that works on a developer’s laptop may fail elsewhere because the other machine lacks its dependencies or has a different configuration. Docker lets you package the application and its dependencies into a container image, then run a container from that image. Developers can work on separate projects without installing every project’s dependencies on their host machine. section 2.0 section 1.1.1
An image is the artifact you download or build; a container is a running instance created from it. Docker can run these instances locally. A Dockerfile records how to prepare an application image, replacing setup instructions that otherwise depend on scripts or memory. Containers also let applications share a host while keeping their environments isolated, with less overhead than full virtual machines. section 2.1.2 section 2.0
Try an isolated shell
Run `docker run -it ubuntu bash`. Docker downloads the Ubuntu image, creates a container, and opens an interactive shell inside it. Installing Python there changes the container environment, not the host. After exiting, use `docker ps -a` to find the stopped container; `docker start` and `docker attach` let you return to it. section 2.1.2
Listing 2.12 Chapter02/2.1.7_CompiledCode/Dockerfile
FROM openjdk COPY . /app WORKDIR /app RUN javac Hello.java #1 CMD java Hello #1 The compile command
For code that needs compilation, this Dockerfile starts from an OpenJDK image, copies the application, sets a working directory, compiles it, and specifies the command to run. Docker can therefore build the program inside the image rather than requiring a locally compiled binary. section 2.1.7
Containerizing an application is a prerequisite for deploying it with Kubernetes, but the tools have different jobs here: Docker supports local building and running, while Kubernetes schedules containers across nodes and manages their lifecycle through a container runtime. Kubernetes configuration names images; the resulting container instances are created at run time and are ephemeral. section 2.0 section 2.1.2 section 3.1.1

























