Docker Associate Certification Flashcards

Flash Cards for the Docker Associate Certification

1
Q

What lists all available/configured Docker networks?

A

docker network ls

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

What performs a Docker service create?

A
  • no volume (–volume or -v)

- –mount [source=/path],target=[path]

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

What is the docker swarm unlock-key --rotate command for?

A

It performs a key rotation for security on a regular basis.

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

How do you export the image ‘httpd:latest’ to a tar file called ‘httpd-latest.tar’?

A

docker save -o httpd-latest.tar httpd:latest

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

What is the Docker command to run a ‘hello-world’ image from the default repository?

A

docker run hello-world

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

What is the command to allow you to log in with the specified username to a remote image repository?

A

docker login –username=[USERNAME]

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

What is the directive within a Dockerfile that creates a mount point inside instantiated containers that can be used to mount external volumes?

A

VOLUME

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

What is the command to list all running swarms in your configuration?

A

docker swarm ls

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

How do you update a previously draining and/or removed node from the swarm cluster?

A

docker node update –availability active [NODE ID]

from master

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

What command stops a ‘stuck’ or ‘frozen’ container called ‘myweb’?

A

docker kill myweb

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

What is the command that lists the services running in your swarm cluster?

A

docker service ls

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

What’s the command to scale the number of instances in your swarm cluster, once the service is already running/deployed?

A

docker service scale [SERVICE NAME]=[NUMBER]

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

What demotes a ‘master’ or ‘manager’ node to a ‘follower’ node?

A

docker node demote [NODE ID]

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

What command promotes a ‘follower’ node to ‘master’ or ‘manager’?

A

docker node promote [NODE ID]

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

How do you create a Docker image from a Dockerfile in the current directory, naming the image ‘myimage:v1’?

A

docker build -t myimage:v1

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

What is the command to create a new Docker network for containers to use called ‘mynet’?

A

docker network create –subnet [RANGE] mynet

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

What command stops a running container called ‘myweb’ 10 seconds after executing the request?

A

docker stop -t 10 myweb

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

How do you find the Docker management token?

A

docker swarm

- join-token manager (to add another manager, following prompts)

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

What is the command to remove a service from your swarm cluster?

A

docker service rm [SERVICE NAME]

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

What is the directive in a Dockerfile that indicates the default command to run in instantiated containers unless overridden at launch time?

A

ENTRYPOINT

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

How do you perform a Docker swarm manager setup?

A

docker swarm

> init –advertise-addr [ip address of manager]

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

How do you create a service called ‘my_example’ with 4 replicas from the indicated image?

A

docker service create –name my_example –replicas 4 [IMAGE SERVICE]

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

What do you use to gracefully remove a node from a swarm cluster?

A

docker swarm leave (on the node to remove)

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

What does the following command do?

docker swarm unlock

A

Prompts for unlock key

25
Q

What is the command used to initialize ‘swarm mode’?

A

docker swarm init

26
Q

How do you take a look at the indicated node to determine its status in the cluster (formatted cleanly)?

A

docker node inspect –pretty [NODE ID] (on the manager)

27
Q

What command provides a ‘human readable’ method of showing the JSON output from inspect commands?

A

docker node inspect –pretty [nodeID]

28
Q

How do you force a Docker Swarm that has lost majority by forcing a new swarm?

A

docker swarm init –force-new-cluster –advertise-addr [IP ADDRESS]
(from ONE of the remaining master nodes)

29
Q

What is the command to list the processes running in your swarm cluster?

A

docker service ps [SERVICE NAME]

30
Q

What returns the status of a Docker Swarm cluster (from the manager node)?

A

docker node ls

31
Q

What is the command to join an existing swarm as a ‘worker’ node?

A

docker swarm join –token [token] [IP]:2377

32
Q

What command lists all available Docker networks in your system or swarm cluster?

A

docker network ls

33
Q

What is the command to initialize a single replica?

A

docker service create [image]

34
Q

How do you copy an image called ‘httpd’ from the default image repository?

A

docker pull httpd:latest
OR
docker pull httpd

35
Q

How do you instantiate a container called ‘myweb’, running non-interactively, from an image called ‘httpd:latest’?

A

docker run -d –name myweb httpd:latest

36
Q

What directive in a Dockerfile that would allow you to install packages to be included with the image during the build process?

A

RUN

37
Q

How do you display a list of all running containers on the system?

A

docker ps

38
Q

What command will remove the image called ‘mistake:v1’ from the local system even if there are containers based on it?

A

docker rmi –force mistake:v1

39
Q

What are the options to create and/or update a service?

A
  • –name [name of service]
  • –publish [#:#] (publish indicated ports and map to underlying host - NOTE: bypasses routing mesh)
  • –env [var=value] (environment variable published to each worker in the swarm)
  • –workdir [directory] (working directory inside the container/service)
  • –user [username] (runas the indicated user)
  • –network [network name] (can be used to bypass the mesh network for an overlay)
  • –replicas [#]
  • –publish-add [#] (add port to host/swarm random high port)
  • –publish [-p] published=[port],target=[port][/protocol TCP or UDP]
  • –secret [filename] (allows the service access to Docker secrets, use this for each secret)
40
Q

What command displays the logs for the specified service in your swarm?

A

docker service logs [SERVICE NAME]

from the manager

41
Q

What is the command for a new swarm that will be locked on initialisation

A

docker swarm init –autolock –advertise-addr [ip of manager]

42
Q

What is the output of the following command?

docker volume ls

A
  • Lists created volumes.

- Will propagate on service creation.

43
Q

What is the Docker logging driver sample configuration (daemon.json)?

A

{
“log-driver”: “syslog”
“log-opts”: {
“labels”: “production_log”,
“env”: “os,customer”
}
}

44
Q

What command determines nodes in a swarm?

A

docker node ls

45
Q

How do you initialize a Docker Swarm in order to make it ready to add nodes and services?

A

docker swarm init –advertise-addr [IP ADDRESS]

46
Q

How do you display all Docker containers (running or stopped), but list ONLY the Container IDs and not the associated names?

A

docker ps -a -q

47
Q

How do you re-initialize the swarm so it does not attempt to reconnect to old nodes?

A

docker swarm init –force-new-cluster

48
Q

How do you deploy a container application as a service?

A

docker service create [SERVICE IMAGE]

49
Q

The directive in a Dockerfile that instantiated containers will listen on the indicated port at launch.

A

EXPOSE

50
Q

What are the options available for the following command?

docker network create

A
  • –driver=overlay
  • –subnet=[network/mask]
  • –gateway=[IP]
  • –ip-range=[subnet/mask] - only good to further divide network from subnet definition
51
Q

How do you set up the docker container inspect [container]?

A
  • grep for ‘IPAddress’ for IP of container
  • grep for ‘Ports’ for port mapping information
  • –format=”{{.NetworkSettings.Networks.[network driver].IPAddress}}”
    > for container IP
52
Q

What command lists all images installed locally on a system?

A

docker images

53
Q

How do you remove a ‘down’ node from a swarm cluster?

A

docker node rm [NODE ID]

on the manager

54
Q

What command will remove a Docker network called ‘mynet’ from the configuration?

A

docker network rm mynet

55
Q

Information about global service.

A
  • Runs on each active node in the swarm, at least one
  • –mode [global] .
  • The replica is a default when not indicated OR when replica number is provided.
56
Q

What command stops a running container called ‘myweb’?

A

docker stop myweb

57
Q

What are the available options for the following command?

docker prune

A
  • –all (-a) - remove unused images (not just dangling)
  • –force (-f) - force removal without prompting
  • –volumes - prune unused volumes as well (not default)
58
Q

What is the shortcut command to remove all stopped containers?

A

docker rm docker ps -a -q

59
Q

What performs a Docker service create?

A
  • no volume (–volume or -v)

- –mount [source=/path],target=[path]