Docker Flashcards
What is required for Docker to run on Windows?
At least Win10
or
Hyper-V enabled
Dockerfile
FROM ubuntu
Run mkdir tmplogs
RUN apt-get install vim
RUN apt-get install htop
Dockerfile - layers?
Each line of the Dockerfile is a layer!
Docker image?
A read-only template that forms the foundation of your application
Docker Container
a Docker image, when it’s run in a host computer, spawns ta process with its own namespace
When container is stopped/killed…?
All changes are lost
Ways to mount data?
Volumes, Bind Mounts, tmpfs
Docker Registry?
Place to store your Docker images
Dockerfile Layers - defined
A FROM instruction that tells Docker what the base image is
An ENV instruction to pass an environment variable
A RUN instruction to run some shell commands (for example, install-
dependent programs not available in the base image)
A CMD or an ENTRYPOINT instruction that tells Docker which executable to
run when a container is started
Docker Engine
Docker Engine is the core part of Docker. Docker Engine is a client-server
application that provides the platform, the runtime, and the tooling for building
and managing Docker images, Docker containers, and more.
Docker CLI commands (the basics)
docker build
docker pull
docker run
docker exec
Docker Compose
Docker Compose is a tool for defining and running multi-container applications
Docker Registry (may need authentication)
the registry is hosted on dockerprivate.registry
WORKDIR
WORKDIR instruction sets the current working directory for RUN, CMD,
ENTRYPOINT, COPY, and ADD instructions
FROM
FROM
As you learned earlier, every image needs to start from a base image
ADD & COPY
ADD and COPY instructions seem to do the same—they allow
you to transfer files from the host to the container’s filesystem
ADD & COPY - differences
COPY supports
basic copying of files to the container, while ADD has support for features like
tarball auto extraction and remote URL support
RUN Command
RUN (known as the shell form) RUN ["executable" , "parameter 1" , " parameter 2"] (known as the exec form)
RUN Example
RUN apt-get update RUN apt-get install foo RUN apt-get install bar RUN apt-get install baz It’s better to wrap them in a single RUN command: RUN apt-get update && apt-get install -y \ foo \ bar \ baz
CMD & ENTRYPOINT
CMD and ENTRYPOINT instructions define which command is executed when
running a container
ENV
The ENV instruction sets the environment variables to the image
VOLUME
The VOLUME instruction tells Docker to create a directory on the host and mount
it to a path specified in the instruction.