Docker Flashcards

1
Q

What are the two most important concepts in Docker?

A

Images and containers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe a Docker image.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What can you think of images as?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe a Docker container.

A

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 .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What can you think of containers as?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a Docker volume?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What’s a Docker network?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the three parts of Docker workflow?

A
  1. Docker Client
  2. Docker Host (Docker Daemon)
  3. Docker Registry (Docker Hub)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is Docker Client?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Docker Host?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is Docker Registry?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Where does creating an image start from?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you specify the base image to use for the new image?

A

FROM: it’s like picking a starting kitchen that already has some basic tools and ingredients.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you set the
working directory for the following instructions?

A

WORKDIR: it’s like deciding where in the kitchen you want to do all your
cooking.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you copy the files or directories from the build context to
the image?

A

COPY: it’s like bringing in your recipe ingredients and any special tools
into your chosen cooking spot.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you execute commands in the shell during image build?

A

RUN: it’s like doing specific
steps of your recipe, such as mixing ingredients.

17
Q

How do you inform Docker that
the container will listen on specified network ports at runtime?

A

EXPOSE: it’s like saying I’m going to use this specific part of the kitchen to serve the food.

18
Q

How do you set environment variables during the build process

A

ENV: you can think of that as setting the kitchen environment such as deciding whether it’s a busy restaurant or a quiet home kitchen.

19
Q

How do you define build time variables?

A

ARG: it’s like having a note that you can change before you start cooking, like deciding if you want to use fresh or frozen ingredients.

20
Q

How do you create a mount point for externally mounted volumes?

A

VOLUME: essentially specifying a location inside your container where you can connect external storage. It’s like leaving a designated space in your kitchen for someone to bring in extra supplies if needed.

21
Q

What provides default command to
execute when the container starts?

A

CMD: it’s like specifying what dish you want to make when someone orders from your menu.

22
Q

What specifies the default executable to be run when the container starts?

A

ENTRYPOINT: it’s like having a default dish on your menu that people will get unless they specifically ask for something else.

23
Q

What’s the difference between ENTRYPOINT and CMD?

A

In simple terms both CMD and entry point are instructions in Docker for defining the default command to run when a container starts. The key difference is that CMD is
more flexible and can be overridden when running the container, while ENTRYPOINT defines the main command that cannot be easily overridden.

Think of CMD as providing a default which can be changed and ENTRYPOINT as setting a fixed starting point for your container. If both are used, CMD arguments will be passed to ENTRYPOINT.

24
Q
A