Containerization Flashcards

1
Q

What is the purpose of containers?

A
  • Isolate software from its surroundings, for example differences between development and staging environments.
  • Help reduce conflicts between teams running different software on the same infrastructure.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to configure a Docker container?

A
  • Create a docker-compose.yml file at the root of a project.
  • This YAML file defines how containers should behave in production.
  • It should specifies the compose file format (or version), the services, networks and volumes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Start a docker container.

A

$ docker-compose up

Shorthand for $ docker-compose build && docker-compose run

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

How to run docker commands without putting a sudo in front of them?

A

Add username to docker group.

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

What is containerization?

A

The process of distributing and deploying apps in a portable and predictable way. It accomplishes this by packaging components and their dependencies into standardized, isolated, lightweight process environments called containers.

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

Describe the docker compose workflow.

A
  1. Define each service in a dockerfile.
  2. Define the services and their relation to each other in the docker-compose.yml file.
  3. Use docker-compose up to start the system.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

List the running docker containers.

A

$ docker-compose ps

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

What are the main functions of docker compose?

A
  • Main: creation of microservice architecture (i.e. containers and the links between them).
  • Building images (if an appropriate dockerfile is provided).
  • Scaling containers running a given service.
  • Healing: re-running containers that have stopped.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a container?

A

A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings.

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

Differences between containers and VMs.

A

Containers:

  • Abstraction of the app layer that packages code and dependencies together.
  • Multiple containers can run on the same machine, sharing the OS kernel and running as isloated processes.
  • Containers take up less space than VMs (~10 MBs) and start almost instantly.

VMs:

  • Abstraction of physical hardware turning one server into many.
  • Hypervisor allows multiple VMs to run on a signle machine.
  • Each VM includes a full copy of an OS, apps, binaries and libraries.
  • VMs takes more space (~10 GBs) and are slow to boot.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a dockerfile?

A

A dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.

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

List local docker images and inspect them.

A

$ docker image ls

$ docker inspect [id]

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

Run services in the background with docker.

A

$ docker-compose up -d

Explanation of -d: “detached mode”

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

Run one-off commands for services with docker-compose.

A

$ docker-compose run [service] [command]

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

Stop services with docker-compose.

A

$ docker-compose stop

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

Stop and remove containers, default network and networks defined in the network section of the compose file with docker-compose. Optional: remove images and volumes.

A

$ docker-compose down

$ docker-compose down –rmi (local/all) –v