Docker Flashcards
What is the Docker command to run a container?
docker run image
docker run -d image
Runs the container in detached mode (in the background)
docker run -p 80:80 image
Map port 80 of the host to port 80 in the container
How to make…
docker run -d -p image
…more compact?
docker run -dp image
What is a container?
A process on the host machine that has been isolated from all other processes of the host machine
What does the process isolation leverages?
the kernel namespaces and cgroups
docker ps
List running containers
When running a container, it uses an _____ filesystem.
isolated
The isolated filesystem that a running container uses is provided by…
a container image
Since the image contains the container’s filesystem, it must contain…
everything needed to run an application - all dependencies, configuration, scripts, binaries, etc.
What is chroot?
?
In order to build our application, we need to use a…
Dockerfile
A Dockerfile is a…
text-based script of instructions that is used to create a container image
The CMD directive specifies…
the default command to run when starting a container from this image
The FROM instructions initializes…
a new build stage and sets the Base Image for subsequent instructions
The WORKDIR instruction sets…
the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD instructions that follow it in the Dockerfile
The COPY instruction copies…
COPY src dest
new files or directories from src and adds them to the filesystem of the container at the path dest
What does the -t flag does?
It tags our image
Command to stop a running container:
docker stop
Command to remove a container that has stopped:
docker rm
What does the -f do in that context:
docker rm -f
It removes the container even if it is running
How do we tag an image?
docker tag imageName newImageName
How do we remove an image?
docker rmi imageId