Docker Flashcards

(68 cards)

1
Q

What are challenges that docker resolves?

A

1) Compatibility
2) Dependencies

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

How to check docker version?

A

docker version

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

Run hub.docker.com/whalesay

A

run docker.com/whalesay cowsay Boo

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

List all running containers

A

ps

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

Show all containers

A

ps -a

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

Stop running container

A

stop

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

Remove container permanently

A

rm

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

List all container images

A

images

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

Remove docker image

A

rmi (all dependent containers are removed)

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

Pull image without running a container

A

pull

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

Why is container in ‘exited’ state?

A

Container is run when underlying process is run, otherwise is not

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

Run sleep cmd on ubuntu

A

docker run ubuntu sleep 5

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

Execute a cmd on a running container

A

exec name-or-id cat /etc/hosts

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

Run in attached mode

A

run domain\centos

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

Run in detached mode

A

1) -d
2) run -d domain/centos

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

Attach container

A

attach name-id

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

What is difference between attached & detached container?

A

1) Attached: currently loaded to shell prompt
2) Detached: running in the background, not currently loaded to shell

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

Specify which version of a container to run with a TAG

A

docker run Ubuntu:17.04

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

Flag to run c7s in interactive mode

A

1) -i
2) docker run -i domain/centos

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

Flag to map host port to c7s port & run

A

1) -p host-port:c7s-port
2) docker run -p 80:5000 domain\centos

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

How to map a volume

A

1) -v host-dir:c7s-dir
2) docker run -v /opt/datadir:/var/lib/mysql mysql

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

Flags to run interactive & pseudo-TTY

A

docker run -it domain/centos

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

Map local port to port of container

A

docker run -p 80:5000 domain/centos

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

Get container info in JSON

A

docker inspect

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Access container log
docker log name-or-id
26
Run c7 selected version with additional cmd
docker run ubuntu:17.10 cat /etc/*release*
27
What is a limiation of running container with specified cmd?
Lack of control of current terminal session until cmd stops
28
How to run background cmd in a container? (detached)
docker run -d ubuntu sleep 15
29
How to go back (attach) to currently run container?
docker attach
30
Forward port & map a volume to a container
run -p 8080:8080 -v /root/dir:var/dir centos
31
Map a volume to a container with credentials (& port map)
run -p 8080:8080 -v /root/dir:var/dir -u root centos
32
Create local image based on Dockerfile with tag
docker build Dockerfile -t domain/centos
33
Make image available on docker-hub
docker push domain/centos
34
How is Dockerfile structured?
INSTRUCTION argument
35
What is first required Dockerfile instruction?
FROM
36
Get access to container history
docker history domain/centos
37
Build docker image from Dockerfile located in current dir
docker build .
38
Build docker image with specified tag-name
docker build . -t my-simple-webapp
39
Tag for push to docker-hub purposes
docker build . -t domain/app-name
40
Login to docker account in terminal
docker login
41
Run simple docker web-app with environment variable
1) -e docker run -e APP_color=blue simple-web-app-color
42
How to find ENV:VAR on a running docker
1) docker inspect 2) Config
43
Example of creating ENV:VAR in Python
color = os.environ.get('APP_COLOR')
44
Examples of CMD usage
1) CMD command param1 = CMD sleep5 2) CMD ["command", "param1"] or CMD ["sleep", "5"]
45
Entrypoint instruction
ENTRYPOINT ["sleep"]
46
How to use default instruction for entrypoint? It can be override
1) ENTRYPOINT ["sleep"] 2) CMD ["5"]
47
What are components of docker engine?
1) Daemon 2) REST API 3) CLI
48
Access docker by remote commands
1) -H=name:port 2) docker -H=remote-docker-engine:2375
49
What are components of docker namespace?
1) InterProcess 2) Mount 3) Network 4) Process ID 5) Unix Timesharing
50
What tools restricts amount of HW resources allocated to a container?
cgroups
51
Cmd to limit cpu usage to 50%
docker run --cpus=.5 centos
52
Cmd to limit memory usage to 100mb
run --memory=100m centos
53
Where docker stores data in linux FS?
/var/lib/docker
54
What architecture is docker based on?
Layered architecture
55
Components of layered architecture
1) OS 2) APT / YUM 3) PIP 4) Source code 5) Entrypoint + 6) Container layer (R/W)
56
Create docker volume dir
docker volume create data_volume
57
Mount volume inside a container
run -v /source-dir:/var/lib/mysql mysql
58
Where are docker volumes created?
/var/lib/docker/volumes
59
Examples of two syntaxes for volume mounting (1)
docker run -v /data/mysql:/var/lib/mysql mysql
60
How docker chooses storage drivers?
Automatically based on OS type
61
What networks are created automatically in docker?
1) Bridge (default) 2) none 3) host
62
List all networks
docker network ls
63
What network feature comes by default with docker? Runs at 127.0.0.11
Embedded DNS
64
What is docker registry?
Central repository of all docker images
65
What is default docker registry?
docker.io
66
What is more secure registry option to use?
Private registry
67
Deploy private registry
docker run -d -p 5000:5000 --name registry regsitry:2
68
Examples of two syntaxes for volume mounting (2)
1) \ --mount 2) run \ --mount type=bind,source=/data/mysql,target=/var/lib/mysql mysql