Docker Flashcards

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
Q

Access container log

A

docker log name-or-id

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

Run c7 selected version with additional cmd

A

docker run ubuntu:17.10 cat /etc/release

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

What is a limiation of running container with specified cmd?

A

Lack of control of current terminal session until cmd stops

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

How to run background cmd in a container? (detached)

A

docker run -d ubuntu sleep 15

29
Q

How to go back (attach) to currently run container?

A

docker attach

30
Q

Forward port & map a volume to a container

A

run -p 8080:8080 -v /root/dir:var/dir centos

31
Q

Map a volume to a container with credentials (& port map)

A

run -p 8080:8080 -v /root/dir:var/dir -u root centos

32
Q

Create local image based on Dockerfile with tag

A

docker build Dockerfile -t domain/centos

33
Q

Make image available on docker-hub

A

docker push domain/centos

34
Q

How is Dockerfile structured?

A

INSTRUCTION argument

35
Q

What is first required Dockerfile instruction?

A

FROM

36
Q

Get access to container history

A

docker history domain/centos

37
Q

Build docker image from Dockerfile located in current dir

A

docker build .

38
Q

Build docker image with specified tag-name

A

docker build . -t my-simple-webapp

39
Q

Tag for push to docker-hub purposes

A

docker build . -t domain/app-name

40
Q

Login to docker account in terminal

A

docker login

41
Q

Run simple docker web-app with environment variable

A

1) -e
docker run -e APP_color=blue simple-web-app-color

42
Q

How to find ENV:VAR on a running docker

A

1) docker inspect
2) Config

43
Q

Example of creating ENV:VAR in Python

A

color = os.environ.get(‘APP_COLOR’)

44
Q

Examples of CMD usage

A

1) CMD command param1 = CMD sleep5
2) CMD [“command”, “param1”] or CMD [“sleep”, “5”]

45
Q

Entrypoint instruction

A

ENTRYPOINT [“sleep”]

46
Q

How to use default instruction for entrypoint? It can be override

A

1) ENTRYPOINT [“sleep”]
2) CMD [“5”]

47
Q

What are components of docker engine?

A

1) Daemon
2) REST API
3) CLI

48
Q

Access docker by remote commands

A

1) -H=name:port
2) docker -H=remote-docker-engine:2375

49
Q

What are components of docker namespace?

A

1) InterProcess 2) Mount 3) Network 4) Process ID 5) Unix Timesharing

50
Q

What tools restricts amount of HW resources allocated to a container?

A

cgroups

51
Q

Cmd to limit cpu usage to 50%

A

docker run –cpus=.5 centos

52
Q

Cmd to limit memory usage to 100mb

A

run –memory=100m centos

53
Q

Where docker stores data in linux FS?

A

/var/lib/docker

54
Q

What architecture is docker based on?

A

Layered architecture

55
Q

Components of layered architecture

A

1) OS
2) APT / YUM
3) PIP
4) Source code
5) Entrypoint +
6) Container layer (R/W)

56
Q

Create docker volume dir

A

docker volume create data_volume

57
Q

Mount volume inside a container

A

run -v /source-dir:/var/lib/mysql mysql

58
Q

Where are docker volumes created?

A

/var/lib/docker/volumes

59
Q

Examples of two syntaxes for volume mounting (1)

A

docker run -v /data/mysql:/var/lib/mysql mysql

60
Q

How docker chooses storage drivers?

A

Automatically based on OS type

61
Q

What networks are created automatically in docker?

A

1) Bridge (default)
2) none
3) host

62
Q

List all networks

A

docker network ls

63
Q

What network feature comes by default with docker? Runs at 127.0.0.11

A

Embedded DNS

64
Q

What is docker registry?

A

Central repository of all docker images

65
Q

What is default docker registry?

A

docker.io

66
Q

What is more secure registry option to use?

A

Private registry

67
Q

Deploy private registry

A

docker run -d -p 5000:5000 –name registry regsitry:2

68
Q

Examples of two syntaxes for volume mounting (2)

A

1) \ –mount
2) run \ –mount type=bind,source=/data/mysql,target=/var/lib/mysql mysql