1. Using Volumes to Develop Applications in Containers Flashcards
What can be said about the mutability of container images?
They are immutable — they don’t change.
How are container images defined?
They are defined declaratively using a text file called Dockerfile.
What does a Dockerfile contain?
A sequence of special instructions that inform Docker on how to create the container image.
What kind of details do Dockerfile instructions define?
- Which base image to use
- Which source files need to be copied from the host into the image
- The command that our container derived from the image will run
- And so on…
What process do we need to get an image built with an application inside it in Docker?
Docker’s image build process.
What happens when an image build is invoked using Docker’s CLI?
Docker reads and acts on the instructions in the Dockerfile, and makes use of any build artefacts such as compiled binaries to assemble the image that embodies the software application or service we want the container to run.
What is a Docker image?
It’s a template for the container.
Where does Docker’s image build process fit into the software development cycle?
Just before we get to the point where we need to run the application, and after we compile it.
What is the drawback of complex image definitions and how can this be alleviated?
Complex image definitions can take a significant amount of time to build and this can severely impact the productivity of a software developer. Our best bet for alleviating this is to develop inside the container where our code is destined to run.
What are the three implications of developing apps inside a container?
- Source code is part of the container’s filesystem
- Can run application and tests using the CLI
- Changes don’t persist on container deletion (ephemeral by nature)
What does Docker use to get around the ephemeral nature of data that’s located within a container’s file system?
Volumes.
What are Docker volumes?
A Docker volume is an area of persistent storage that is located outside of the container.
Where are Docker volumes located?
On the host that’s running Docker, on the network, or even cloud storage.
How does Docker use to work with volumes?
Volume plug-ins — a plug-in system for implementing storage solutions.
How does Docker provide access to data stored outside of the container?
It mounts the storage area into the container during the life of the container and unmounts the storage when it gets removed.
What are the three types of Docker volumes?
- Tmpfs Mount
- Named or Anonymous Volume
- Bind Mount
What are Tmpfs mounts?
Temporary areas of storage that mounts a storage location in the memory onto a destination in the container’s file system.
What is the primary use case of Tmpfs mounts?
Writing sensitive data to the container’s file system during its execution without ever touching a disk and becoming open to compromise.
What are named or anonymous volumes?
A designated area of storage that resides within a protected area under Docker’s control.
How can named or anonymous volumes be manipulated?
Using Docker CLI.
What do bind mounts allow us to do?
Mount an arbitrary directory on the host onto an arbitrary target location inside a container.
What can be said about the changes made inside a bind mount in terms of reflection?
Changes made in the bind mound from the container are reflected on the host and vice versa.
What is the explicit approach of creating a Docker volume?
Running the
volume subcomand in the Docker CLI along with the verb create
and specifying a name for the volume.
docker volume create code-volume
What is the explicit approach of creating a Docker volume?
Running the volume
subcomand in the Docker CLI along with the verb create
and specifying a name for the volume.
docker volume create code-volume