DCA Flashcards
What are the components of Docker Engine?
- REST API, Docker Daemon
- Images, Containers, Volumes
- Docker CLI, Docker Daemon, REST API
Docker CLI, Docker Daemon, REST API
What component of the docker engine manages the images, containers, volumes, and networks on a host?
- REST API
- Docker Daemon
- Docker CLI
Docker Daemon
What component of the Docker architecture is responsible for managing containers on Linux on version 1.15 of Docker Engine?
- LibContainer
- Docker API
- LXC
LibContainer
We can run containers without installing Docker?
- True
- False
True
Which component is responsible for keeping the containers alive when the Docker Daemon goes down?
- LibContainer
- Runc
- Containerd
- Containerd-Shim
Containerd-Shim
What are the primary objects that Docker engine manages?
- RunC
- LibContainer
- Images, Containers, Volumes, Networks
- Images, Containers, Volumes, Networks
By default, data stored inside the container is always persistent?
- True
- False
False
By default, Docker is configured to look for images on Google Cloud Registry?
- True
- False
False
Which component is a read-only template used for creating a Docker container?
- Docker Network
- Docker Images
- Container
- Docker volume
Docker Images
What is the default data directory for Docker?
- /var/lib/docker
- /var/log/docker
- /etc/docker
- /home/docker
/var/lib/docker
What does OCI stand for?
- Open Communication Initiative
- Open Container Initiative
- Open Command Interface
- Open Container Interface
Open Container Initiative
What are the 2 specifications from OCI?
- container-spec
- runtime-spec
- image-spec
- oci-spec
- libcontainer-spec
- runtime-spec
- image-spec
What is the command to view the version of docker engine installed?
- docker –version
- docker version
- docker engine info
- docker info engine
docker version
What is the command to start docker daemon manually?
- docker
- dockerd
- docker-engine
- docker –start-engine
dockerd
On what interfaces are the docker daemon made available by default?
- TCP socket
- UDP socket
- Unix socket
- 192.168.1.10
Unix Socket
What is the port conventionally used to configure un-encrypted traffic on TCP?
- 2345
- 2346
- 2375
- 2376
2375
What file is used to configure the docker daemon?
- /var/lib/docker/docker.conf
- /var/lib/docker/daemon.json
- /etc/docker/daemon.json
- /etc/docker/daemon.conf
- /etc/docker/daemon.json
What flags are used to configure encryption on docker daemon?
- tlsverify, tlscert, tlskey
- tlsverify, key, cert
- key, cert, tls
- host, key, cert, tls
tlsverify, tlscert, tlskey
What is the default network driver used when a container is created?
- overlay
- bridge
- none
- host
bridge
What is the command used to list the running containers on the Docker Host?
- docker container ls
- docker container start
- docker container stop
- None of the above
docker container ls
Which of the below commands create a container with nginx image and name nginx?
- docker container create nginx –name nginx
- docker container –name nginx nginx
- docker container run nginx
- docker container create –name nginx nginx
docker container create –name nginx nginx
How to list all running and stopped containers and their status?
- docker container ls
- docker container ls -a
- docker container ls -aq
- docker container ls -q
docker container ls -a
How to start a stopped Container?
docker container start nginx
How do I get only the IDs of running containers?
docker container ls -q
What is the option used in docker run command to attach to the terminal of the container in an interactive mode?
-it
What is the command to change the container name “httpd” to “webapp”?
- docker container rename httpd webapp
- docker container rename webapp httpd
- docker container replace –name httpd webapp
- docker container create –name webapp httpd
docker container rename httpd webapp
What is the command to run a “nginx” container in a detached mode with name “webapp”?
- docker container run -it –name webapp nginx
- docker container run -it –name nginx webapp
- docker container run -d –name webapp nginx
- docker container run -d –name nginx webapp
docker container run -d –name webapp nginx
You cannot start a killed container?
- True
- False
False
Delete the stopped container named “webapp”.
- docker container delete webapp
- docker container remove webapp
- docker container kill webapp
- docker container rm webapp
docker container rm webapp
Run a container called webapp with image nginx, and in an interactive mode.
- docker container run -it nginx
- docker container run -it nginx –name webapp
- docker container run nginx
- docker container run -it –name webapp nginx
- docker container run -it –name webapp nginx
Which combination of keys are used to escape from the shell and keep the container webapp running?
- Ctrl + c
- Ctrl+p+q
- exit, Ctrl+p+q
- Ctrl+c,exit
Ctrl+p+q
Which combination of keys are used to exit from the shell and stop the container webapp?
- Ctrl+c
- Ctrl+p+q
- Ctrl+p
- Ctrl+z
Ctrl+c
You have a running container and want to execute a command inside it. Which command will you use?
- execute
- run
- start
- exec
exec
We deployed a container called webapp. Inspect this container to get the IPPrefixLen
- docker container inspect webapp | grep IPPrefixLen
- docker container top webapp | grep IPPrefixLen
- docker container run webapp | grep IPPrefixLen
- docker container logs webapp | grep IPPrefixLen
docker container inspect webapp | grep IPPrefixLen
We have deployed some containers. What command is used to get the container with the highest memory?
- docker container stats
- docker container status
- docker container top
- docker container ls
docker container stats
How to display the running processes inside the container?
- docker container top container-name
- docker container stats container-name
- docker ps container-name
- docker container logs container-name
docker container top container-name
You have a webapp container and image httpd.
Inspect the logs of the webapp container.
Which command is used to get the stream logs of the webapp container so that you can view the logs live?
docker container logs -f webapp
Which command returns only new and/or live events?
- docker system info
- docker container events
- docker container events -f
- docker system events
docker system events
Which command returns events since the paste 30 minutes?
- docker system events since 30m
- docker system events –since 30m
- docker container events –since 30m
- docker container events since 30m
docker system events –since 30m
Which command is used to get the events of the container named “webapp”? (This one is for you to read the documentation)
- docker system events since 10m
- docker system events –filter ‘container=webapp’
- docker system events –filter ‘image=webapp’
docker system events –filter ‘container=webapp’
Run a container named webapp with nginx image in detached mode. Select the right answer.
- docker container run –detach –name=webapp nginx
- docker container run –detach –name=nginx webapp
- docker container create -d –name=nginx webapp
- docker container create -d nginx
docker container run –detach –name=webapp nginx
Stop the container named “nginx”
- docker container halt nginx
- docker container stop nginx
- docker container rm nginx
- docker container pause nginx
docker stop container nginx
How do you list running & stopped containers?
- docker container ls -a
- docker container ls -q
- docker container ls
- docker container ls -q, docker container ls
docker container ls -a
Delete the “webapp” Container. Select the right answer.
- docker container delete webapp
- docker container remove webapp
- docker container kill webapp
- docker container rm webapp
docker container rm webapp
Stop all running containers on the host. Select the right answer.
- docker container stop $(docker container ls -a)
- docker container rm $(docker container ls -q)
- docker container stop $(docker container ls -q)
- docker container stop –all
docker container stop $(docker container ls -q)
Delete all running and stopped containers on the host. (Explore the documentation to identify an option to force remove running containers)
- docker container stop $(docker container ls -q)
- docker container rm $(docker container ls -q)
- docker container stop $(docker container ps -q)
- docker container rm -f $(docker container ls -aq)
docker container rm -f $(docker container ls -aq)
Which command is used to delete the stopped containers?
- docker container remove $(docker container ls -aq)
- docker container rm $(docker container ls -aq)
- docker container prune
- docker container rm –all
docker container prune
What is the command to pause a running container?
- docker container pause
- docker container –pause
- docker container halt
- docker container SIGSTOP
docker container pause
What are the signals sent to a running container when the docker container stop command is executed?
- SIGSTOP followed by SIGKILL
- SIGTERM followed by SIGKILL
- SIGKILL followed by SIGTERM
- SIGKILL followed by SIGSTOP
SIGTERM followed by SIGKILL
Run a container with image nignx, name nginx and hostname webapp.
- docker container run -d –name webapp –hostname=webapp nginx
- docker container run -d –name nginx webapp
- docker container run -d –name nginx –hostname=webapp nginx
- docker container run -d –name webapp nginx
docker container run -d –name nginx –hostname=webapp nginx
What is the hostname set on the container when the following command is run: docker container run -d –name webapp httpd
- webapp
- apache
- httpd
- containers unique id
containers unique id
What is the default restart policy?
- unless-stopped
- on-failure
- no
- always
no
Which policy would restart the containers even after the docker daemon is restarted?
- unless-stopped
- on-failure
- always
- always, unless-stopped
always
Which policy is used to restart a container unless it is explicitly stopped or Docker is restarted?
- unless-stopped
- on-failure
- no
- always
unless-stopped
Which command can be used to check the restart policy of webapp container?
- docker container inspect webapp
- docker container info webapp
- docker container check webapp
- None of above
docker container inspect webapp
Restart container unless it is explicitly stopped or Docker is restarted.
- unless-stopped
- on-failure
- no
- always
unless-stopped
Which command should be used to update the httpd container with the always policy?
- docker container update –restart always httpd
- docker container unpause –restart always httpd
- docker container upgrade –restart always httpd
docker container update –restart always httpd
Which command should be used to update all the running containers with unless-stopped policy?
- docker container upgrade –restart unless-stopped $(docker container ls -q)
- docker container update –restart unless-stopped $(docker container ls -q)
- docker container upgrade –restart unless-stopped $(docker container ls -aq)
- docker container update –restart unless-stopped $(docker container ls -aq)
docker container update –restart unless-stopped $(docker container ls -q)
Which option is used to reduce container downtime due to daemon crashes, planned outages, or upgrades?
- Restart Policy
- Swarm
- LIve Rest
Live Restore
What is the path file which is used to add the live restore?
- /etc/docker/daemon.json
- /var/lib/docker/daemon.json
- /var/log/docker/daemon.json
- /var/lib/docker
/etc/docker/daemon.json
How to enable the live restore setting to keep containers alive when the daemon becomes unavailable?
- echo ‘{“live-restore”: true}’»_space; /etc/docker/daemon.json
- echo ‘{“live-restore”: true}’»_space; /var/lib/docker/daemon.json
- echo ‘{true: “live-restore”}’»_space; /etc/docker/daemon.json
- echo ‘{true: “live-restore”}’»_space; /var/lib/docker/daemon.json
echo ‘{“live-restore”: true}’»_space; /etc/docker/daemon.json
Which of the below commands may be used to copy a file /web.conf from a container named webapp with id 89683681 to the /tmp directory on the host?
- docker container cp /tmp/web.conf webapp:/etc/web.conf
- docker container cp webapp:/web.conf /webapp
- docker container cp 89683681:/web.conf /tmp/
- docker container cp webapp:/web.conf /tmp/
docker container cp webapp:/web.conf /tmp/
Copy the /etc/nginx directory from the webapp container to the docker host under /tmp/.
- docker container copy webapp:/etc/nginx /tmp/
- docker container cp webapp:/etc/nginx /tmp/
- docker container copy /tmp/ webapp:/etc/nginx
- docker container cp /tmp/ webapp:/etc/nginx
docker container cp webapp:/etc/nginx /tmp/
What is the command to copy the file /root/myfile.txt from the host to /root/ of the webapp container?
- docker container copy /root/myfile.txt webapp:/root/
- docker container cp /root/myfile.txt webapp:/root/
- docker container copy webapp:/root/ /root/myfile.txt
- docker container cp webapp:/root/ /root/myfile.txt
docker container cp /root/myfile.txt webapp:/root/
We can copy a file from a stopped container?
- True
- False
True
Data inside a container is persistent?
True
False
False
You can run multiple instances of the same application on the docker host?
True
False
True
You can map the same port on the Docker host more than once?
False
Which option could be used to expose a webapp container to the outside world?
- p
- P
- -publish
- -expose
- p
- P
- -publish
Map TCP port 80 in the container to port 8080 on the Docker host for connections to host IP 192.168.1.10 . Select the all right answers
- p 192.168.1.10:8080:80
- p 192.168.1.10:80:8080
- p 192.168.1.10:8080:80/tcp
- p 192.168.1.10:8080:8080
-p 192.168.1.10:8080:80
Unless specified otherwise, docker publishes the exposed port on all network interfaces.
- True
- False
True
Map UDP port 80 in the container to port 8080 on the Docker host.
-p 8080:80/udp
-p 80:8080/udp
-P 8080:80/udp
None of the above
-p 8080:80/udp
How does the -P option in the docker container run command know what ports to publish on the container?
- It identifies the ports listening inside the container using netstat command
- It uses the ExposedPorts field set on the container or the EXPOSE instruction in the Dockerfile
- It requires the –expose command line argument
- It assigns random ports between 32768 and 61000
It uses the ExposedPorts field set on the container or the EXPOSE instruction in the Dockerfile
How does docker map a port on a container to a port on the host?
- Using an internal load balancer
- FirewallD Rules
- Using an external load balancer
- IPTables Rules
IPTables Rules
What IPTables chains does Docker modify to configure port mapping on a host?
- INPUT
- FORWARD
- DOCKER
- OUTPUT
DOCKER
How to check the logs of the docker daemon?
- journalctl -u docker.service
- less /var/log/messages
- less /var/log/daemon.log
- /var/log/docker.log
journalctl -u docker.service
less /var/log/messages
less /var/log/daemon.log
/var/log/docker.log
Enable the debugging mode. Select the right answer
- echo ‘{“debug”: true}’ > /etc/docker/daemon.json
- echo ‘{“debug”}’ > /etc/docker/daemon.json
- echo ‘{“debug”: true}’ > /var/lib/docker/daemon.json
- echo ‘{“debug”}’ > /var/lib/docker/daemon.json
echo ‘{“debug”: true}’ > /etc/docker/daemon.json
How to check if the docker service is running or not?
- docker status
- sudo systemctl status docker
- sudo systemctl docker status
- sudo service status docker
sudo systemctl status docker
Which environment variable will be used to connect a remote docker server?
- DOCKER_REMOTE
- DOCKER_HOST
- DOCKER_CONFIG
None of the above
DOCKER_HOST
What may be the cause of this error: “unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: tls: (from flag: true, from file: false)”?
The tls flag is set to true in daemon.json file and false in the command line
The tls flag is set to false in daemon.json file and true in the command line
The tls flag is not set on the command line
The tls flag is not set in the daemon.json file
The tls flag is set to false in daemon.json file and true in the command line
What is the default logging driver?
json-file
syslog
journald
splunk
json-file
Where is the log of the webapp container with id 78373635 on the Docker Host?
/var/lib/docker/containers/78373635/78373635.json
/var/log/docker/78373635.json
/etc/docker/78373635.json
/var/lib/docker/tmp/78373635/78373635.json
/var/lib/docker/containers/78373635/78373635.json
Which command is used to check the default logging driver?
docker system df
docker system events
docker system prune
docker system info
docker system info
How to change the default logging driver to syslog?
echo ‘{“log-driver”: “syslog”}’ > /etc/docker/daemon.json
echo ‘{“syslog”: “log-driver”}’ > /etc/docker/daemon.json
echo ‘{“log-driver”: “syslog”}’ > /var/lib/docker/daemon.json
echo ‘{“syslog”: “log-driver”}’ > /var/lib/docker/daemon.json
echo ‘{“log-driver”: “syslog”}’ > /etc/docker/daemon.json
Run a webapp container, and make sure that no logs are configured for this container.
docker run -it –log-driver none webapp
docker run -it –logging-driver none webapp
docker run -it webapp
docker run -it –log none webapp
docker run -it –log-driver none webapp
Which of the below commands create a container with redis image and name redis?
docker container create redis –name redis
docker container –name redis redis
docker container run redis
docker container create –name redis redis
docker container create –name redis redis
We have deployed some containers. What command is used to get the container with the highest memory?
docker container stats
docker container status
docker container top
docker container ls
docker container stats
Run a container called apps with image nginx, and in an interactive mode.
docker container run -it nginx
docker container run -it nginx –name apps
docker container run nginx
docker container run -it –name apps nginx
docker container run -it –name apps nginx
You can run multiple instances of the same application on the docker host.
True
False
True
Which of the below commands create a container with redis image and name redis?
docker container create redis –name redis
docker container –name redis redis
docker container run redis
docker container create –name redis redis
docker container create –name redis redis
Which command should be used to update the restart policy of the httpd container with always?
docker container update –restart always httpd
docker container unpause –restart always httpd
docker container upgrade –restart always httpd
None of the above
docker container update –restart always httpd
You can map multiple containers to the same port on the Docker host.
True
False
False
Which command is used to check the default logging driver?
docker system df
docker system events
docker system prune
docker system info
docker system info
What is the command to copy the file /root/myconfig.txt from the host to /root/ of the data container?
docker container copy /root/myconfig.txt data:/root/
docker container cp /root/myconfig.txt data:/root/
docker container copy data:/root/ /root/myconfig.txt
docker container cp data:/root/ /root/myconfig.txt
docker container cp /root/myconfig.txt data:/root/
Which command is used to update all running containers with the <code>unless-stopped</code> restart policy?
docker container upgrade –restart unless-stopped $(docker container ls -q)
docker container update –restart unless-stopped $(docker container ls -q)
docker container upgrade –restart unless-stopped $(docker container ls -aq)
docker container update –restart unless-stopped $(docker container ls -aq)
docker container update –restart unless-stopped $(docker container ls -aq)
What is the purpose of a private registry?
tightly control where your images are being stored
fully own your images distribution pipeline
integrate image storage and distribution tightly into your in-house development workflow
All of the above
All of the above
What is the default public registry for docker?
Docker Hub
Amazon Container Registry
Google Container Registry
Docker Trusted Registry
Docker Hub
What is the default tag if not specified when building an image with the name webapp?
none
default
latest
v1
latest
Run ubuntu container with the trusty tag.
docker run ubuntu
docker run ubuntu:latest
docker run ubuntu:trusty
docker run ubuntu -t trusty
docker run ubuntu:trusty
Select the right answer. Which command is used to list the local images?
docker image ls
docker images ls
docker container image ls
docker container images ls
docker image ls
List the full length image IDs. (Please explore documentation)
docker image ls –digests
docker images –digests
docker images –no-trunc
None of the above
docker images –no-trunc
Display images with a name containing postgres, at least 12 stars.
docker find –filter=stars=12 postgres
docker search –filter=stars=12 postgres
docker find –limit=12 postgres
docker search –limit=12 postgres
docker search –filter=stars=12 postgres
Download nginx image from the Google Container Registry hub registry.
docker image pull nginx
docker image build nginx
docker image load nginx
docker pull gcr.io/kodekloud/nginx
docker pull gcr.io/kodekloud/nginx
Display images with a name containing busybox, at least 3 stars and are official builds.
docker find –filter is-official=true –filter stars=3 busybox
docker search –filter is-official=true –filter stars=3 busybox
docker find –filter is-official=true –limit=3 busybox
docker search –filter is-official=true –limit=3 busybox
docker search –filter is-official=true –filter stars=3 busybox
What is the command to change the tag of “httpd:latest” to “httpd:v1” ?
docker container image retag httpd:latest httpd:v1
docker container image tag httpd:latest httpd:v1
docker image retag httpd:latest httpd:v1
docker image tag httpd:latest httpd:v1
docker image tag httpd:latest httpd:v1
You have an nginx:v1 image with size 100M. You’ve now created your own version of the image – nginx:v2 by retagging the first image, what is the total size of both?
50M
100M
150M
200M
100M
Which command should be used to get the total size consumed by all images on a host?
docker image list
docker image df
docker system df
docker system list
docker system df
In the output of the “docker system df” command what does the ACTIVE field indicate on the images row?
Number of Images currently available on the system
Number of Images built on the system
Number of Images with containers
Number of containers running on the system
Number of Images with containers
What command might have generated the above output?
docker container ps
docker ps
docker image ps
docker image list
docker image list
Inspect the following output and answer the following questions:
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest c39a868aad02 4 days ago 150MB
redis latest 4760dc956b2d 2 years ago 100MB
ubuntu trusty f975c5035748 2 years ago 100MB
webapp latest c39a868aad02 4 days ago 150MB
alpine latest 3fd9065eaf02 2 years ago 5MB
What is the total space consumed by images on this system?
355 MB
505 MB
405 MB
455 MB
355 MB
When you run the docker image inspect ubuntu command it gives the error “No such image”. Why is that?
Must run the command docker inspect ubuntu/ubuntu
Image Ubuntu does not have the latest tag
Must authenticate to docker hub first before running this command
Must run the command docker image history ubuntu
Image Ubuntu does not have the latest tag
What is the user/account and image/repository name for the image company/nginx?
image=company, user=nginx
image=company, user=company
image=nginx, user=nginx
image=nginx, user=company
image=nginx, user=company
Choose the right command to pull ubuntu image from a private registry at gcr.io
docker pull ubuntu
docker pull kk/ubuntu
docker pull gcr.io/kk/ubuntu
All of the above
docker pull gcr.io/kk/ubuntu
Which command is used to authenticate with azr.com registry which listens on port 5000?
docker auth azr.com:5000
docker login azr.com:5000
docker login azr.com:5000
You are required to store a copy of the official alpine image in your company’s internal docker registry. What would be your approach?
Create a Dockerfile similar to the official image and build an image
Pull the official image, tag it with the address of the internal docker registry and push to the internal docker registry
Pull the official image, tag it with the address of the internal docker registry and push to the internal docker registry
When you log in to a registry, the command stores credentials in … (Please explore the documentation pages for this)
$HOME/.docker/config.json
/etc/docker/.docker/config.json
/var/lib/docker/.docker/config.json
/var/lib/docker/containers/.docker/config.json
$HOME/.docker/config.json
While trying to delete image postgres, you got an error “conflict: unable to remove repository reference “postgres” (must force) – container 1a56b95e073c is using its referenced image adf2b126dda8″. What may be the cause of this error?
A container is using this image
Must use force option to delete an image
Another image is using layers from this image
The image was built locally on this host
A container is using this image
Which command is used to remove webapp:v1 image locally?
docker image rm webapp
docker image rm webapp:v1
docker image remove webapp:v1
docker image del webapp:v1
docker image rm webapp:v1
Remove all unused images on the Docker host
docker image prune -a
docker image rm -a
docker image delete -a
None of the above
docker image prune -a
Display all layers of httpd image along with the size on each layer.
docker image layers httpd
docker image history httpd
docker image inspect httpd
docker images history httpd
docker image history httpd
Which command can be used to get the ExposedPorts of a webapp image?
docker container ls
docker image inspect webapp
docker container inspect webapp
docker image ls
docker image inspect webapp
How to get the Os field alone of the httpd image?
docker image inspect httpd -f ‘{{.Os}}’
docker image ls | grep Os
docker image history | grep Os
docker image inspect httpd -f ‘{{.OperatingSystem}}’
docker image inspect httpd -f ‘{{.Os}}’
Which subcommand will be used to get more info about images?
inspect
load
import
ls
inspect
Print the value of ‘Architecture’ and ‘Os’ for a ‘webapp’ image.
docker image inspect webapp -f ‘{{.Os}}’ -f ‘{{.Architecture}}’
docker image inspect webapp -f ‘{{.Os}} {{.Architecture}}’
docker image inspect webapp -f ‘{{.Os}}’, -f ‘{{.Architecture}}’
docker image inspect webapp -f ‘{{.Os .Architecture}}’
docker image inspect webapp -f ‘{{.Os}} {{.Architecture}}’
Which command can be used to get a backup of image webapp?
docker image backup webapp -o webapp.tar
docker image save webapp -o webapp.tar
docker container save webapp -o webapp.tar
docker container backup webapp -o webapp.tar
docker image save webapp -o webapp.tar
A tarfile – nginx.tar – has been created using the docker image save command. Which command can be used to extract it into your docker host.
docker image import -i nginx.tar
docker image restore -i nginx.tar
docker container restore -i nginx.tar
docker image load -i nginx.tar
docker image load -i nginx.tar
A government facility runs a secure data center with no internet connectivity. A new application requires access to docker images hosted on docker hub. What is the best approach to solve this?
Get the Dockerfile of the image and build a local version from within the restricted environment.
Establish a secure link between the host in the restricted environment and docker hub
Pull docker images from a host with access to docker hub, convert to a tarball using docker image save command, and copy to the restricted environment and extract the tarball
Pull docker images from a host with access to docker hub, then push to a registry hosted within the restricted environment.
Pull docker images from a host with access to docker hub, convert to a tarball using docker image save command, and copy to the restricted environment and extract the tarball
You have created a nginx container and customized it to create your own webpage. How can you create an image out of it to share with others?
docker image save
docker image export
docker export
You can only create an image using a Dockerfile
docker export
How do you restore an image created from the docker export command?
docker container import
docker image import
docker image load
docker image restore
docker image import
The “export” command works with Docker images.
True
False
False
Export webapp container’s filesystem as a tar archive. Select the right answer
docker export webapp mywebapp.tar
docker image export –output=”mywebapp.tar” webapp
docker image save -i mywebapp.tar
docker container export webapp > mywebapp.tar
docker container export webapp > mywebapp.tar
Which of the following commands is used to list the docker images on the Docker Host?
docker images
docker image ls
docker image get
docker ls image
docker image
Which of the following commands used to match all images with the com.example.version label?
docker images –label=”com.example.version”
docker images –filter “com.example.version”
docker images –filter “label=com.example.version”
docker images –format “label=com.example.version”
docker images –filter “label=com.example.version”
Which of the following is not an instruction supported in the Dockerfile? Select the all right answers.
EXPOSE
ADD
WORKDIR
EXEC
EXEC
The … is a text document that contains all the commands a user could call on the command line to assemble an image.
Dockerfile
Docker Compose
.dockerignore
build context
Dockerfile
Which method can be used to build an image using existing containers?
docker commit
docker export
docker save
docker load
docker export
The container being committed and its processes will be paused while the image is committed.
True
False
True
We have a running container named webapp with the nginx image. We added a custom html file to this container. How do we create an image named mynginx from this container?
docker container commit webapp mynginx
docker container commit mynginx webapp
docker container update webapp mynginx
None of the above
docker container commit webapp mynginx
The docker container commit is the recommended approach for building a custom image.
True
False
False
You are required to create an image from an existing image. What is the recommended approach?
Use docker image export and docker image import command
Use docker container export and docker container import command
Use docker image save and docker image load command
Use docker container commit command
Use docker image save and docker image load command
You are required to create an image from an existing container. What is the recommended approach?
Use docker image export and docker image import command
Use docker container export and docker container import command
Use docker container commit command
Use docker container export and docker image import command
Use docker container export and docker image import command
FROM python:3.6 RUN pip install flask COPY . /opt/ EXPOSE 8080 WORKDIR /opt ENTRYPOINT ["python", "app.py"]
What is the parent image from which this application is created?
ubuntu:latest
python
centos:7
python:3.6
python:3.6
FROM python:3.6 RUN pip install flask COPY . /opt/ EXPOSE 8080 WORKDIR /opt ENTRYPOINT ["python", "app.py"]
To what location within the container is the application code copied to?
/opt
/app
/root
/var
/opt
FROM python:3.6 RUN pip install flask COPY . /opt/ EXPOSE 8080 WORKDIR /opt ENTRYPOINT ["python", "app.py"]
When a container is created using the image built with the following Dockerfile, what is the command used to RUN the application inside it.
pip install flask
docker run app.py
app.py
python app.py
python app.py
FROM python:3.6 RUN pip install flask COPY . /opt/ EXPOSE 8080 WORKDIR /opt ENTRYPOINT ["python", "app.py"]
What is the port of the web application configured for the service to listen within the container?
8080
5000
80
0.0.0.0
What is the port of the web application configured for the service to listen within the container?
8080
5000
80
0.0.0.0
Whenever a build is initiated by running the Docker build command, the files under the build context are transferred to the Docker daemon, at a temporary directory under the docker’s filesystem. Which directory are these files stored in?
/var/lib/docker/tmp
/var/lib/docker/image
/var/lib/docker/volumes
/var/lib/docker/plugins
/var/lib/docker/tmp
Which of the below commands may be used to build an image with the Dockerfile filename?
docker build .
docker build -f Dockerfile .
docker build -t Dockerfile2 .
docker build -t .
docker build .
docker build -f Dockerfile .
While building a docker image from code stored in a remote URL, which command will be used to build from a directory called docker in the branch dev?
docker build https://github.com/kk/dca.git#dev:docker
docker build https://github.com/kk/dca.git#docker:dev
docker build https://github.com/kk/dca.git:dev
docker build https://github.com/kk/dca.gitdev:#docker
docker build https://github.com/kk/dca.git#dev:docker
A build’s context is the set of files located in the specified PATH or URL, Which kind of resources can the URL parameter refer to ?
Git repositories
pre-packaged tarball contexts
Path to a local directory
Git repositories
Path to a local directory
Choose the correct flag to apply a tag to an image done.
- i
- p
- f
- t
-t
If you do not specify a tag name, you can’t build the image.
True
False
False
Build an image using a context build under path /tmp/docker and name it webapp.
docker build /tmp/docker
docker build /tmp/docker -t webapp
docker build webapp -t /tmp/docker
docker pull -it /tmp/docker bash
docker build /tmp/docker -t webapp
What is the default tag if not specified when building an image with the name webapp?
none
default
latest
v1
latest
What is the command to build an image using a Dockerfile.dev file under path /opt/myapp with the name webapp. The current directory you are in is /tmp.
docker build Dockerfile.dev -t webapp /opt/myapp
docker build -f /opt/myapp/Dockerfile.dev /opt/myapp -t webapp
docker build -f Dockerfile.dev /opt/myapp -t webapp
docker build -t Dockerfile.dev -name webapp -f /opt/myapp
docker build -f /opt/myapp/Dockerfile.dev /opt/myapp -t webapp
What is the file used to exclude temporary files such as log files or builds from the context during a build?
.git
.gitignore
.dockerignore
None of the above
.dockerignore
If the build fails at a particular stage, it repurposes the previous layers from the cache and does not really rebuild them.
True
False
True
What is a recommended approach for installing packages and libraries while building an image?
Download packages on the host and use ADD instructions to add them to the image.
Use the ADD instruction to provide a URL to the package on the remote host.
Use the RUN instruction and have the apt-get update and apt-get install commands on the same instruction.
Use the RUN instruction and have the apt-get update and apt-get install commands as separate instructions.
Use the RUN instruction and have the apt-get update and apt-get install commands on the same instruction.
Using RUN apt-get update && apt-get install -y ensures your Dockerfile installs the latest package versions with no further coding or manual intervention. This technique is known as …..
Docker-stack
Cache busting
Version pinning
Build-context
Cache busting
What is a best practice while installing multiple packages as part of the install instruction?
Add them on the same line
Add them on separate lines separated by a slash in alphanumeric order
Add a separate instruction for each package
Add them on separate lines separated by a slash
Add them on separate lines separated by a slash in alphanumeric order
Which among the following scenarios will lead to docker invalidating cache on a given layer?
Change in instruction
Change in a file used with the ADD instruction
Addition of a new instruction at the end of the file
Release of a new version of a package installed with the RUN instruction
Change in instruction
Change in a file used with the ADD instruction
…… forces the build to install a particular version of package regardless of what’s in the cache. This technique can also reduce failures due to unanticipated changes in required packages.
Docker-stack
Cache busting
Version pinning
Build-context
version pinning
What is a recommended approach to reduce build time while building docker images?
Instructions likely to change more often must be at the top of the Dockerfile
Instructions likely to change more often must be at the bottom of the Dockerfile
Instructions likely to change more often must be in the middle of the Dockerfile
The order of the instructions within the Dockerfile doesn’t matter.
Instructions likely to change more often must be at the bottom of the Dockerfile
What is a recommended approach to reduce build time while building docker images?
Instructions likely to change more often must be at the top of the Dockerfile
Instructions likely to change more often must be at the bottom of the Dockerfile
Instructions likely to change more often must be in the middle of the Dockerfile
The order of the instructions within the Dockerfile doesn’t matter.
Instructions likely to change more often must be at the bottom of the Dockerfile
A Dockerfile is built from the Ubuntu image as the base image. What would happen to the cache when a new version of the Ubuntu image is made available at Dockerhub?
Cache is invalidated and docker pulls the new image and recreates from scratch.
Cache is not invalidated and docker continues to use existing cache.
The cache is not invalidated and docker continues to use the existing cache.
Which option can be used to disable the cache while building a docker image? (Explore the docker documentation for this)
–no-cache=true
–force-rm=true
–cache-from true
None of the above
–no-cache=true
COPY instruction only supports the basic copying of local files into the container.
True
False
True
What is the right instruction to download a file from “https://file.tar.xz” and copy to “/testdir” in the image?
ADD https://file.tar.xz /testdir
COPY https://file.tar.xz /testdir
RUN https://file.tar.xz /testdir
None of the above
ADD https://file.tar.xz /testdir
COPY instruction has some features like local-only tar extraction and remote URL support.
True
False
False
Which instruction(s) can be used in the Dockerfile to copy content from the local filesystem into the containers?
ADD
COPY
MOVE
RUN
ADD
COPY
Which of the following is the correct format for CMD instruction?
CMD [“executable”,”param1”,”param2”]
CMD [“param1”,”param2”]
CMD command param1 param2
CMD command,param1,param2
CMD [“executable”,”param1”,”param2”]
CMD command param1 param2
If CMD is used to provide default arguments for the ENTRYPOINT instruction, both the CMD and ENTRYPOINT instructions should be specified.
True
False
True
When a user runs the command docker run my-custom-image sleep 1000
docker overrides the ENTRYPOINT instruction with “sleep 1000”
docker overrides the CMD instruction with “sleep 1000”
docker override ENTRYPOINT instruction with “sleep” and CMD instruction with “1000”
docker overrides the CMD instruction with “sleep 1000”
Choose the correct instruction to add the echo “Hello World” command in the Dockerfile.
CMD [echo “Hello World”]
CMD [“echo”, “Hello World”]
CMD [“Hello World”]
None of the above
CMD [“echo”, “Hello World”]
What is the output of the following Dockerfile snippet when container runs as docker run -it < image> ?
ENTRYPOINT [“/bin/echo”, “Hello”]
CMD [“world”]
Hello world
Hello
world
world Hello
Hello world
What is the output of the following Dockerfile snippet when container runs as docker run -it kk ?
ENTRYPOINT [“/bin/echo”, “Hello”]
CMD [“World”]
Hello kk
Hello
World kk
kk Hello
Hello kk
f you list more than one CMD instruction in the Dockerfile then only the last CMD will take effect.
True
False
True
A parent image is an image that your image is based on. It refers to the contents of the FROM directive in the Dockerfile.
True
False
True
A parent image has FROM scratch in its Dockerfile.
True
False
False
While building an image, You have one base image, but there could be multiple parent images.
True
False
True
How do you identify if a Docker file is configured to use multi-stage builds?
The Dockerfile has the tag multi-stage at the top
The Dockerfile has multiple FROM instructions
The Dockerfile has multiple RUN instructions
The Dockerfile is built from the scratch image
The Dockerfile has multiple FROM instructions
The “–from=0” in the following Dockerfile instruction line refers to:
“COPY –from=0 /go/src/github.com/alexellis/href-counter/app .”
The base image specified in the FROM instruction of the first set of instructions.
The base image specified in the FROM instruction of the second set of instructions.
The image built using the first set of instructions in the Dockerfile.
The image built using the last set of instructions in the Dockerfile
The image built using the first set of instructions in the Dockerfile.
By default, the stages are not named, and you refer to them by their integer number, starting with 1 for the first FROM instruction in the multi-stage build.
True
False
False
Name the stage which uses nginx as a base image to builder in the Dockerfile.
FROM nginx
FROM nginx AS builder
The last image build
FROM node AS builder
FROM nginx AS builder
What is the instruction used to copy a file from an external image named redis not part of any stage in the multi-stage build process. (Refer to the documentation for this one)
–from=redis
–from=0
–copy-from=redis
–copy-from=0
–from=redis
You are developing an e-commerce application. The application must store cart details of users temporarily as long as the user’s session is active. What is the recommended approach to storing the cart details with the application deployed as a docker container?
Store the cart details in the /tmp directory of the container
Store the cart details in the memory of the container
Store the cart details in a volume backed by a in-memory cache service like redis
Store the cart details in a volume backed by a in-memory cache service like redis
It’s recommended to avoid sending unwanted files to the build context by using .gitignore file to exclude those files.
True
False
False
An application you are developing requires an httpd server as frontend, a python application as the backend API server, a MongoDB database and a worker developed in Python. What is the recommended approach in building images for these containers?
Build httpd, python API server, MongoDB database, and Python worker into a single image to allow ease of deployment
Build httpd into an image, MongoDB database to another, and Python API and worker together into a single image
Build separate images for each component of the application
Build separate images for each component of the application
Which of the below can help minimize the image size?
Only install necessary packages within the image
Avoid sending unwanted files to the build context using .dockerignore
Combine multiple dependent instructions into a single one and clean up temporary files
Move the instructions that are likely to change most frequently to the bottom of the Dockerfile
Use multi-stage builds
- Only install necessary packages within the image
- Combine multiple dependent instructions into a single one and clean up temporary files
- Use multi-stage builds
Which is the recommended approach to install packages following the best practices in Dockerfile?
RUN apt-get update && apt-get install -y git httpd
RUN apt-get update && apt-get install -y \
git \
httpd
RUN apt-get update \
RUN apt-get install -y git \
RUN apt-get install -y httpd
RUN apt-get update && apt-get install -y \
git \
httpd
Which of the below steps can help minimize the build time of images?
Only install necessary packages within the image
Avoid sending unwanted files to the build context using .dockerignore
Combine multiple dependent instructions into a single one and clean up temporary files
Move the instructions that are likely to change most frequently to the bottom of the Dockerfile
Use multi-stage builds
- Avoid sending unwanted files to the build context using .dockerignore
- Move the instructions that are likely to change most frequently to the bottom of the Dockerfile
Which of the following tag image will get when creating a redis container with image redis?
docker run -itd –name redis redis
none
default
v1
latest
latest
Which of the below statements are true:
By default a container runs with 1 vCPU and 500 MB of memory
By default a container runs with unlimited CPU and Memory resources
By default a container runs with 0.5 vCPU and 500 MB of memory
By default a container runs with unlimited vCPU and 500 MB of memory
By default a container runs with unlimited CPU and Memory resources
What will happen if the –memory-swap is set to -1?
the container does not have access to swap.
the setting is ignored, and the value is treated as unset.
the container is allowed to use unlimited swap.
None of the above
the container is allowed to use unlimited swap.
Each container gets a CPU share of …. assigned by default.
256
512
1024
2048
1024
What is a linux feature that prevents a process within the container to access raw sockets?
Control Groups (CGroups)
Namespaces
Kernel Capabilities
Network Namespaces
Kernel Capabilities
By default, all containers get the same share of CPU cycles. How to modify the shares?
docker container run –cpu-shares=512 nginx
docker container run –cpuset-cups=512 nginx
docker container run –cpu-quota=512 nginx
docker container run –cpus=512 nginx
docker container run –cpu-shares=512 nginx
Which command is used to list the default available networks? docker network --filter docker network get docker network ls None of the above
docker network ls
Which command is used to see the network settings and IP address assigned to a container with id c164825bb3d3 that uses the myapp image?
docker inspect myapp
docker container ls myapp
docker container ls c164825bb3d3
docker inspect c164825bb3d3
docker inspect c164825bb3d3
What is the default network driver used on a container if you haven’t specified one?
host
bridge
overlay
Macvlan
bridge
Overlay networks connect multiple Docker daemons together and enable swarm services to communicate with each other.
True
False
True