Docker Flashcards
What are the two most important concepts in Docker?
Images and containers
Describe a Docker image.
Image is a lightweight standalone executable package that includes
everything needed to run a piece of software including the code run times like node.js, libraries system tools , and even the operating system.
What can you think of images as?
As a recipe for our application. It not only lists the ingredients, being code
and libraries, but also provides the instructions such as runtime and system tools to create a specific meal, meaning to run our application.
Describe a Docker container.
A Docker container is a runnable instance of a Docker image. It represents the execution
environment for a specific application, including its code, runtime, system tools,
and libraries included into Docker image. A container takes everything specified in the image and follows its instructions by executing necessary commands, downloading packages, and setting things up to run our application .
What can you think of containers as?
Imagine having a recipe for a
delicious cake, the recipe being the docker image. Now when we actually bake the ingredients we can serve it as a cake. The baked cake is like a Docker container, it’s the real thing
created from the recipe. Just like we can have multiple servings of the same meal from a single recipe or multiple documents created from a single database schema we can run multiple containers from a single image. That’s what makes Docker the best, we create one image and
get as many instances as we want from it in form of containers.
What is a Docker volume?
Docker volume is a persistent data storage mechanism that allows data to to be shared between a dock container and the
host machine which is usually a computer or a server or even among multiple containers. It ensures data durability and persistence even if the container is stopped or removed. Think of it as a shared folder or a storage compartment that exists outside the container.
What’s a Docker network?
It’s a communication channel that enables different Docker containers to talk to each each other or with the external world. It creates connectivity, allowing containers to share information and
services while maintaining isolation. Think of a Docker Network as a big
restaurant kitchen. In a large kitchen, being the host, you have different cooking stations, or containers, each
focused on a specific meal, meal being our application. Each cooking station or a container is like a chef working independently on a meal. Now imagine a system of order tickets or a Docker Network connecting all of these cooking stations together. Chefs can communicate, ask for ingredients or share recipes seamlessly even though each station or container has its own space and focus. The communication system or the docker Network enables them to collaborate efficiently. They share information
without interfering with each other’s cooking process.
What are the three parts of Docker workflow?
- Docker Client
- Docker Host (Docker Daemon)
- Docker Registry (Docker Hub)
What is Docker Client?
Docker Client is the user interface for interacting with Docker. It’s the tool we use to give Docker commands. We issue commands to the Docker Client via the command line or a graphical user interface, instructing it to build, run, or manage images or containers. Think of the
docker client as the chef giving instructions to the kitchen staff.
What is Docker Host?
Docker Host, or Docker Daemon, is the background process responsible for managing containers on the host system. It listens for Docker Client commands, creates and manages containers, builds images, and handles other Docker-related tasks. Imagine the Docker Host as the Master Chef overseeing the kitchen,
carrying out instructions given by the chef, or the Docker Client.
What is Docker Registry?
Docker Registry, aka Docker Hub, is a centralised repository of Docker images. It hosts both public and private Registries or packages. Docker is to Docker Hub what Git is to GitHub. In a nutshell, Docker images are stored in these Registries and when you run a container, Docker may pull the required image from the registry if it’s unavailable locally. To return to our cooking analogy, think of Docker Registry as a cookbook or recipe Library. It’s like a popular cookbook store where you can find and share different recipes, in this case Docker images.
Where does creating an image start from?
Starts from a special file called Docker File. It’s a
set of instructions telling Docker how to build an image for your application.
How do you specify the base image to use for the new image?
FROM: it’s like picking a starting kitchen that already has some basic tools and ingredients.
How do you set the
working directory for the following instructions?
WORKDIR: it’s like deciding where in the kitchen you want to do all your
cooking.
How do you copy the files or directories from the build context to
the image?
COPY: it’s like bringing in your recipe ingredients and any special tools
into your chosen cooking spot.