April 24, 2024

Docker

Docker images

Dockerfiles are used by Docker to build images. It is basically a text file that contains all instructions needed to build an image. Each instruction adds a layer to the previous layer.

Typical instructions in a Dockerfile

FROM windows/iis
RUN mkdir -p C:\app
COPY app C:/app
WORKDIR c:/app
RUN npm install
CMD node index.js
  • FROM – specify a docker image. This is the base layer.
  • COPY – add files from your current directory to the docker image
  • RUN – is a image build step, which executes a command
  • CMD – is a command that is run against the built image

Build a Docker image from the Dockerfile with:

docker build [OPTIONS] PATH | URL | -

When you run an image and generate a container, you add a new writable layer on top of the underlying layers. All changes made to the running container, such as writing new files, modifying existing files, and deleting files, are written to this thin writable container layer.

Docker cheat sheet from [https://www.docker.com/sites/default/files/d8/2019-09/docker-cheat-sheet.pdf]