Docker Associate Certification Flashcards
Flash Cards for the Docker Associate Certification
What lists all available/configured Docker networks?
docker network ls
What performs a Docker service create?
- no volume (–volume or -v)
- –mount [source=/path],target=[path]
What is the docker swarm unlock-key --rotate
command for?
It performs a key rotation for security on a regular basis.
How do you export the image ‘httpd:latest’ to a tar file called ‘httpd-latest.tar’?
docker save -o httpd-latest.tar httpd:latest
What is the Docker command to run a ‘hello-world’ image from the default repository?
docker run hello-world
What is the command to allow you to log in with the specified username to a remote image repository?
docker login –username=[USERNAME]
What is the directive within a Dockerfile that creates a mount point inside instantiated containers that can be used to mount external volumes?
VOLUME
What is the command to list all running swarms in your configuration?
docker swarm ls
How do you update a previously draining and/or removed node from the swarm cluster?
docker node update –availability active [NODE ID]
from master
What command stops a ‘stuck’ or ‘frozen’ container called ‘myweb’?
docker kill myweb
What is the command that lists the services running in your swarm cluster?
docker service ls
What’s the command to scale the number of instances in your swarm cluster, once the service is already running/deployed?
docker service scale [SERVICE NAME]=[NUMBER]
What demotes a ‘master’ or ‘manager’ node to a ‘follower’ node?
docker node demote [NODE ID]
What command promotes a ‘follower’ node to ‘master’ or ‘manager’?
docker node promote [NODE ID]
How do you create a Docker image from a Dockerfile in the current directory, naming the image ‘myimage:v1’?
docker build -t myimage:v1
What is the command to create a new Docker network for containers to use called ‘mynet’?
docker network create –subnet [RANGE] mynet
What command stops a running container called ‘myweb’ 10 seconds after executing the request?
docker stop -t 10 myweb
How do you find the Docker management token?
docker swarm
- join-token manager (to add another manager, following prompts)
What is the command to remove a service from your swarm cluster?
docker service rm [SERVICE NAME]
What is the directive in a Dockerfile that indicates the default command to run in instantiated containers unless overridden at launch time?
ENTRYPOINT
How do you perform a Docker swarm manager setup?
docker swarm
> init –advertise-addr [ip address of manager]
How do you create a service called ‘my_example’ with 4 replicas from the indicated image?
docker service create –name my_example –replicas 4 [IMAGE SERVICE]
What do you use to gracefully remove a node from a swarm cluster?
docker swarm leave (on the node to remove)
What does the following command do?
docker swarm unlock
Prompts for unlock key
What is the command used to initialize ‘swarm mode’?
docker swarm init
How do you take a look at the indicated node to determine its status in the cluster (formatted cleanly)?
docker node inspect –pretty [NODE ID] (on the manager)
What command provides a ‘human readable’ method of showing the JSON output from inspect commands?
docker node inspect –pretty [nodeID]
How do you force a Docker Swarm that has lost majority by forcing a new swarm?
docker swarm init –force-new-cluster –advertise-addr [IP ADDRESS]
(from ONE of the remaining master nodes)
What is the command to list the processes running in your swarm cluster?
docker service ps [SERVICE NAME]
What returns the status of a Docker Swarm cluster (from the manager node)?
docker node ls
What is the command to join an existing swarm as a ‘worker’ node?
docker swarm join –token [token] [IP]:2377
What command lists all available Docker networks in your system or swarm cluster?
docker network ls
What is the command to initialize a single replica?
docker service create [image]
How do you copy an image called ‘httpd’ from the default image repository?
docker pull httpd:latest
OR
docker pull httpd
How do you instantiate a container called ‘myweb’, running non-interactively, from an image called ‘httpd:latest’?
docker run -d –name myweb httpd:latest
What directive in a Dockerfile that would allow you to install packages to be included with the image during the build process?
RUN
How do you display a list of all running containers on the system?
docker ps
What command will remove the image called ‘mistake:v1’ from the local system even if there are containers based on it?
docker rmi –force mistake:v1
What are the options to create and/or update a service?
- –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)
What command displays the logs for the specified service in your swarm?
docker service logs [SERVICE NAME]
from the manager
What is the command for a new swarm that will be locked on initialisation
docker swarm init –autolock –advertise-addr [ip of manager]
What is the output of the following command?
docker volume ls
- Lists created volumes.
- Will propagate on service creation.
What is the Docker logging driver sample configuration (daemon.json)?
{
“log-driver”: “syslog”
“log-opts”: {
“labels”: “production_log”,
“env”: “os,customer”
}
}
What command determines nodes in a swarm?
docker node ls
How do you initialize a Docker Swarm in order to make it ready to add nodes and services?
docker swarm init –advertise-addr [IP ADDRESS]
How do you display all Docker containers (running or stopped), but list ONLY the Container IDs and not the associated names?
docker ps -a -q
How do you re-initialize the swarm so it does not attempt to reconnect to old nodes?
docker swarm init –force-new-cluster
How do you deploy a container application as a service?
docker service create [SERVICE IMAGE]
The directive in a Dockerfile that instantiated containers will listen on the indicated port at launch.
EXPOSE
What are the options available for the following command?
docker network create
- –driver=overlay
- –subnet=[network/mask]
- –gateway=[IP]
- –ip-range=[subnet/mask] - only good to further divide network from subnet definition
How do you set up the docker container inspect [container]?
- grep for ‘IPAddress’ for IP of container
- grep for ‘Ports’ for port mapping information
- –format=”{{.NetworkSettings.Networks.[network driver].IPAddress}}”
> for container IP
What command lists all images installed locally on a system?
docker images
How do you remove a ‘down’ node from a swarm cluster?
docker node rm [NODE ID]
on the manager
What command will remove a Docker network called ‘mynet’ from the configuration?
docker network rm mynet
Information about global service.
- 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.
What command stops a running container called ‘myweb’?
docker stop myweb
What are the available options for the following command?
docker prune
- –all (-a) - remove unused images (not just dangling)
- –force (-f) - force removal without prompting
- –volumes - prune unused volumes as well (not default)
What is the shortcut command to remove all stopped containers?
docker rm docker ps -a -q
What performs a Docker service create?
- no volume (–volume or -v)
- –mount [source=/path],target=[path]