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
Data Persistence
Traditionally, VMs store persistent data, containers do, usually, not
26
Strategies to persist data
mpfs mounts Bind mounts Volumes
27
tmpfs Mounts
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
Bind Mounts
In bind mounts, the file/directory on the host machine is mounted into the container.
29
Bind Mount VS. Docker Volume
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
Preferred flag for Mounting?
--mount
31
Example of Mount | mounting host's home directory, to a directory called 'host-name' within the container
``` 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
Volumes
Docker volumes are the current recommended method of persisting data stored in containers
33
Volume Advantages
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
Docker Volume Commands
``` docker volume create docker volume inspect docker volume ls docker volume prune docker volume rm ```
35
Example Volume command
docker volume create --name=nginx-volume
36
Default Docker Network Drivers
``` bridge host overlay macvlan none ```
37
Bride Network
Allows for containers to communicate together
38
Host Network
Connects containers to the Docker Host
39
Overlay Network
Creates a network spanning multiple docker hosts | primarily used when a cluster of Docker hosts are setup in Swarm mode
40
Macvlan Network
leverage the Linux kernel’s ability to assign multiple | logical addresses based on MAC to a single physical interface
41
None Network
the container has no Network
42
Docker Compose
Simplifies creating Containers for different needs
43
Docker Compose file?
.yml
44
Docker Compose File Versioning
1 2. x 3. x
45
Services
Services is the first root key of the Compose YAML and is the configuration of the container that needs to be created
46
build
The build key contains the configuration options that are applied at build time.
47
context
sets the context to build
48
image
if present, will build the image and name/tag it
49
environment/env_file
stores the keys and values for the build
50
ports
specifies the ports that will be exposed to the port
51
volumes
adds a named volume to the build
52
depends_on
pulls dependency requirements
53
Restart
key that provides the restart policy for the container | By default, set to "no", never restart
54
Docker Compose - build
reads the Compose file, scans for build keys ie docker-compose build
55
Docker Compose - down
``` stops the containers and will proceed to remove containers, volumes, networks dockercompse down(?) ```
56
Docker Compose - exec
lets you run ad hoc commands of any containers
57
Docker Compose - command
docker-compose