Docker Flashcards
What is Docker?
Docker is a tool for creating, deploying, and running applications easily
Why use Docker?
Docker allows to packge applications with all their dependencies and distribute them as individual bundles with that Docker guarantees that the applications will run the same way on every Docker instance
What is a Docker image?
A docker image is a file that represents a packaged application with all the dependencies needed to run correctly -> An image is like a java class
How are docker images built?
Docker images are built as series of layers and these layers are assembled on top of one another and simply put, a layer is an image
What do we need for a Docker image of a Hello World application?
- Operating System Layer
- JVM
- Hello World application
What is a docker container?
A docker container is an instance of an image and can be identified by its ID -> A docker container is like an instance of a java class
What are the states for a container that docker defines?
Created, restarting, running, removing, paused, exited, and dead
What are the advantages of containers?
- Containers are lightweight VMs
- Their behaviors are completely isolated from each other
- Easy way of scaling applications because we can run multiple containers of the same image at the same time
What is usually the first layer of a docker image?
The first layer of a docker image is usually the operating system
How can we pass environment variables to docker containers?
- Using -env, -e
- Using -env-file
- Using docker compose
What ways of interactive exploring are there to check configurations or log files inside a container?
- Running a container with shell access using the docker run command with the -it option
- Spawning a shell in a running container with docker exec
- Non-interactive exploring
- Copying the filesystem
What ways are there to copy files to and from a docker container?
- Using the docker cp command
- Volume mounts
- Dockerfile with COPY
When can we use the docker cp command?
Docker cp cannot be used to copy between two containers. It can only be used to copy files between the host system and a single container
What is a bind mount?
A docker bind mount is a high-performance connection from the container to a directory on the host machine -> It allows the host to share its own file system with the container, which can be made read-only or read-write
What is a volume mount?
A volume is a directory on the host machine that is accessible to a container, so that the data is not stored in the container’s filesystem but instead it is stored in the host machine filesystem. The data persists even if the container is deleted or recreated