General Flashcards

1
Q

Which one is more portable: containers or VMs?

A

Containers. They are more lightweight and therefore, more portable

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

Can containers run inside VMs?

A

Yes

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

Are the majority of containers in circulation Linux or Windows based?

A

Linxus based. They are smaller than Windows containers

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

What is Docker?

A

Docker is a platform for building and managing containers

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

Since Docker is Linux based, how is it possible for it to run on Windows or Mac?

A

Docker runs inside a VM for Windows (WSL 2) and Mac

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

Give an illustration of Docker’s architecture

A
  1. Docker Client (CLI, Docker Desktop communcaties with dockerd)
  2. dockerd (Restful API that delegates to containerd)
  3. containerd (Manages the lifecycle of containers)
  4. runc (container runtime that executes containers)
  5. Host OS
  6. Host hardware
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Describe the role of dockerd

A

dockerd provides an API to docker clients. It delegates most of the work to containerd

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

Describe the role of containerd

A

containerd manages images and the lifecycle of containers. it uses instances of runc to build, run, and remove containers by passing an image to it

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

What is the role of runc

A

runc is a stand-alone container runtime that interacts with the host OS to build, run, and remove containers. As soon as containers are built, runc terminates and the containerd’s shim process becomes the parent process for the running container. This is done so that Docker avoids having dozens of runc instances for running containers

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

Is a docker host and a docker node the same thing?

A

Yes

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

What is the role of a shim?

A

To become the parent process of a container after runc creates it. It also reports back to containerd when a container terminates

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

What is a container?

A

A container is an instance of an image

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

What is a Dockerfile?

A

A Dockerfile is a file containing all of the instructions necessary to build a container image. Dockerfiles are normallyu located in the root directory of an application.

docker build [Options] [path]

Is the command used to build images by specifying the path to the Dockerfile

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

What is an image and what is it composed of?

A

An image is a template for building containers. It is composed of a stack of independent layers where the base layer is usually a lightweight OS (no kernel) that provides a CLI to interact with the container

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

What is a registry?

A

A registry is a collection of repositories for images. Docker Hub is the default registry for Docker Desktop

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

Give an illustration of the structure of a registry

A
  1. Registry
  2. N Repositories per registry
  3. N images per repository
17
Q

What happens when you don’t specify a tag when pulling an image?

A

The “latest” tag is used implicitly

18
Q

True or False

It’s a good practice to specify the version of the image you are pulling instead of using the “latest” tag

A

True

19
Q

How do image layers make images more space efficient?

A

Image layers can be shared by different images. This means that image layers can be stored locally and be reused by multiple images

20
Q

What is a digest and why is it used?

A

A digest is a hash over the contents of an image. It is used so that an image can be recognized even if it happens to have the same name as another image but with older code

21
Q

What is a manifest list and what is it used for?

A

A manifest list is a list of the CPU architectures that an image supports. Each CPU architecture has its own manifest that lists the layers used to build that image. This makes it easy to pull images with the right CPU architecture since Docker pulls the proper image by parsing the manifest list

22
Q

If you have 2 images stored locally and they have some layers in common, will deleting one of the images remove all of the layers stored locally?

A

No. If there is another image that shares some of the layers, those layers that are being shared will not be deleted until the second image is deleted

23
Q

What is Docker buildx?

A

Docker buildx is a plugin that extends the Docker CLI to support multi-arch builds

24
Q

What happens if you kill the main process (PID 1) of a container?

A

The container will also be killed

25
Q

Does stopping a container destroy the data that was persisted inside of it?

A

No. However, it’s important to remember that containers are designed to be immutable and persisting data inside them is an anti-pattern. You should use volumes instead

26
Q

Where can you specify what app should be loaded by default when running a container?

A

Dockerfile Entrypoint

27
Q

When specifying the layers in a dockerfile, which layers should be at the top?

A

The layer that is bound to be changed the most so that caching can be optimized.

28
Q

Should dockerfiles be kept in a VCS?

A

Yes

29
Q

Do images need to be tagged before you can push them?

A

Yes

30
Q

Which of the following dockerfile commands build layers and which provide metadata: FROM, RUN, COPY, EXPOSE, WORKDIR, ENV, ENTRYPOINT?

A

Build layers:
* FROM
* RUN
* COPY

Provide metadata:
* EXPOSE
* WORKDIR
* ENV
* ENTRYPOINT

31
Q

What is the purpose of using multi-stage builds?

A

The end result is a tiny production image with nothing but the binary inside. None of the build tools required to build the application are included in the resulting image

32
Q

Does each container have its own hostname, IP address, and ports?

A

Yes. Each container has its own hostname, which by default is its own container ID. Each container also has its own IP address for every network it attaches to. Technically, a container receives an IP address out of the IP subnet of the network.

33
Q

What is a volume?

A

A volume is a directory in the host machine that can be mounted to a directory inside a container so that data generated by the container can be persisted externally

34
Q

Does a volume increase the size of the containers using it?

A

No

35
Q

Will a volume’s data continue to persist outside a container’s lifecycle?

A

By default, data will continue to persist even if a container has been stopped or removed. There are CLI commands that can override this behavior.

36
Q

What is the Container Layer?

A

The Container Layer is a writable layer that sits on top of the container image layers. The container layer is created when a container is executed. Essentially, all changes made to the running container, such as writing new files, modifying existing files, and deleting files, are written to this thin writable container layer. This layer is also ephemeral, which means that when the container is deleted, the contents of the writable layer are also deleted.