Docker Flashcards

1
Q

What is required for Docker to run on Windows?

A

At least Win10
or
Hyper-V enabled

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

Dockerfile

A

FROM ubuntu
Run mkdir tmplogs
RUN apt-get install vim
RUN apt-get install htop

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

Dockerfile - layers?

A

Each line of the Dockerfile is a layer!

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

Docker image?

A

A read-only template that forms the foundation of your application

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

Docker Container

A

a Docker image, when it’s run in a host computer, spawns ta process with its own namespace

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

When container is stopped/killed…?

A

All changes are lost

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

Ways to mount data?

A

Volumes, Bind Mounts, tmpfs

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

Docker Registry?

A

Place to store your Docker images

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

Dockerfile Layers - defined

A

A FROM instruction that tells Docker what the base image is
An ENV instruction to pass an environment variable
A RUN instruction to run some shell commands (for example, install-
dependent programs not available in the base image)
A CMD or an ENTRYPOINT instruction that tells Docker which executable to
run when a container is started

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

Docker Engine

A

Docker Engine is the core part of Docker. Docker Engine is a client-server
application that provides the platform, the runtime, and the tooling for building
and managing Docker images, Docker containers, and more.

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

Docker CLI commands (the basics)

A

docker build
docker pull
docker run
docker exec

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

Docker Compose

A

Docker Compose is a tool for defining and running multi-container applications

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

Docker Registry (may need authentication)

A

the registry is hosted on dockerprivate.registry

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

WORKDIR

A

WORKDIR instruction sets the current working directory for RUN, CMD,
ENTRYPOINT, COPY, and ADD instructions

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

FROM

A

FROM

As you learned earlier, every image needs to start from a base image

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

ADD & COPY

A

ADD and COPY instructions seem to do the same—they allow

you to transfer files from the host to the container’s filesystem

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

ADD & COPY - differences

A

COPY supports
basic copying of files to the container, while ADD has support for features like
tarball auto extraction and remote URL support

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

RUN Command

A
RUN  (known as the shell form)
RUN ["executable"
,
"parameter 1"
,
" parameter 2"]
(known as the exec form)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

RUN Example

A
RUN apt-get update
RUN apt-get install foo
RUN apt-get install bar
RUN apt-get install baz
It’s better to wrap them in a single RUN command:
RUN apt-get update && apt-get install -y \
foo \
bar \
baz
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

CMD & ENTRYPOINT

A

CMD and ENTRYPOINT instructions define which command is executed when
running a container

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

ENV

A

The ENV instruction sets the environment variables to the image

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

VOLUME

A

The VOLUME instruction tells Docker to create a directory on the host and mount
it to a path specified in the instruction.

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

EXPOSE

A

The EXPOSE instruction tells Docker that the container listens for the specified
network ports at runtime

24
Q

LABEL

A

The LABEL instruction adds metadata to an image as a key/value pair.

25
Q

Data Persistence

A

Traditionally, VMs store persistent data, containers do, usually, not

26
Q

Strategies to persist data

A

mpfs mounts
Bind mounts
Volumes

27
Q

tmpfs Mounts

A

The directories mounted in tmpfs appear as a
mounted filesystem but are stored in memory, not to persistent storage such as a
disk drive.

28
Q

Bind Mounts

A

In bind mounts, the file/directory on the host machine is mounted into the
container.

29
Q

Bind Mount VS. Docker Volume

A

By contrast, when using a Docker volume, a new directory is created
within Docker’s storage directory on the Docker host and the contents of the
directory are managed by Docker

30
Q

Preferred flag for Mounting?

A

–mount

31
Q

Example of Mount

mounting host’s home directory, to a directory called ‘host-name’ within the container

A
docker run -it --name mount-test --mount
type=bind,source="$HOME"
,target=/host-home ubuntu bash
docker run -it --name mount-test -v $HOME:/host-home
ubuntu bash
32
Q

Volumes

A

Docker volumes are the current recommended method of persisting data stored
in containers

33
Q

Volume Advantages

A

Volumes are easier to back up or transfer than bind mounts
Volumes work on both Linux and Windows containers
Volumes can be shared among multiple containers without problems

34
Q

Docker Volume Commands

A
docker volume create
docker volume inspect
docker volume ls
docker volume prune
docker volume rm
35
Q

Example Volume command

A

docker volume create –name=nginx-volume

36
Q

Default Docker Network Drivers

A
bridge
host
overlay
macvlan
none
37
Q

Bride Network

A

Allows for containers to communicate together

38
Q

Host Network

A

Connects containers to the Docker Host

39
Q

Overlay Network

A

Creates a network spanning multiple docker hosts

primarily used when a cluster of Docker hosts are setup in Swarm mode

40
Q

Macvlan Network

A

leverage the Linux kernel’s ability to assign multiple

logical addresses based on MAC to a single physical interface

41
Q

None Network

A

the container has no Network

42
Q

Docker Compose

A

Simplifies creating Containers for different needs

43
Q

Docker Compose file?

A

.yml

44
Q

Docker Compose File Versioning

A

1

  1. x
  2. x
45
Q

Services

A

Services is the first root key of the Compose YAML and is the configuration of
the container that needs to be created

46
Q

build

A

The build key contains the configuration options that are applied at build time.

47
Q

context

A

sets the context to build

48
Q

image

A

if present, will build the image and name/tag it

49
Q

environment/env_file

A

stores the keys and values for the build

50
Q

ports

A

specifies the ports that will be exposed to the port

51
Q

volumes

A

adds a named volume to the build

52
Q

depends_on

A

pulls dependency requirements

53
Q

Restart

A

key that provides the restart policy for the container

By default, set to “no”, never restart

54
Q

Docker Compose - build

A

reads the Compose file, scans for build keys
ie
docker-compose build

55
Q

Docker Compose - down

A
stops the containers and will proceed to remove containers, volumes, networks
dockercompse down(?)
56
Q

Docker Compose - exec

A

lets you run ad hoc commands of any containers

57
Q

Docker Compose - command

A

docker-compose