NEW
Font size
WorksheetsWorking with Docker Registries, Images and Containers
Total questions: 44
Worksheet time: 44mins
You require access to a self-hosted registry. When must the --insecure-registry config option must be configured on the Docker daemon?
When the registry is being served from the loopback network.
When the registry uses a self-signed certificate for authentication.
When the registry is configured to receive API calls over plain HTTP.
I have pulled the latest image to my machine and a new image is pushed to the registry, which now has the latest tag, what happens when I build a new container?
Docker will fetch the latest image with the latest tag and you will get an image that is based on the newer version.
Docker will reuse the already fetched image with the latest tag and you will get an image that is based on an old version.
It will not build the image.
If you have a registry that services images over http, what is that called?
Insecure registry
Web registry
http registry
Private registry
Why is the domain name of the registry important?
So users can easily use the registry API.
It's included in the image name
You have to configure the docker engine with it.
What is the purpose of a registry?
To store images.
To store dockerfiles.
To store containers.
To store compose files.
You are required to containerize a NodeJS application. Which base image would you choose to use to derive your application image in order to ensure fitness for purpose and to minimize the size of the resultant image?
The official NodeJS image based on Alpine Linux from the Docker HUB registry, because Alpine Linux is highly optimized.
The official Ubuntu image from the Docker HUB registry, because it is the most popular image available.
The official NodeJS image based on Debian Wheezy from Docker HUB registry, because Debian has been around for more than 20 years.
Create your own NodeJS base image, because the content of the images from the Docker HUB registry cannot be trusted.
When authoring a Docker image using a multi-stage build, the final FROM instruction should be FROM scratch, in order to produce the smallest image possible. Is this good advice?
Sometimes - the base image for the final build stage should, ultimately, be an image that serves the purpose of the image being authored.
Never - the artifacts contained within an image will always have a need for the content of a filesystem, that is provided by base image.
Always - it's of the utmost importance to produce as small an image as is possible, whenever you author a Docker image.
Which of the following is an advantage of Multi-stage Builds?
Multi-platform images
Smaller images
Faster image builds
Better image documentation
Which of the following is recommended best practice?
Use large images containing lots of tools
Keep your images small
Never use that latest image in a repo
Only use Docker Hub
What's special about a multi-stage build?
Automatically merge filesystems between stages.
Copy files between stages.
A process in one stage can manipulate the filesystem of another stage.
Processes can talk to each other between stages.
What is the purpose of an image?
To provide a traditional process for an application.
To provide an isolated process for an application.
To provide the network configuration for an application's network stack.
To provide the filesystem for an application.
What does * mean in the .dockerignore file?
Exclude all files.
Exclude files with an * in the path.
Include all files.
Exclude files with an * in the file system.
Which COPY syntax is used to copy from a previous stage?
FROM build-env:/source /dest
CP build-env:/source /dest
COPY build-env:/source /dest
COPY --from=build-env /source /dest
Given this Dockerfile. How many build targets (aka stages) are there?
2
4
3
1
What's a substantial benefit of a multi-stage build?
Create fewer layers.
Separate build and runtime concerns.
Decreased storage requirements from build cache.
What is the role of NGINX with ReactJS applications?
NGINX stores configuration settings.
NGINX serves static content/reverse proxy.
NGINX is an engine used to run any language.
NGINX acts as a Java Server.
By default where are Docker daemon logs sent to on a Linux system running systemd?
syslog
jounald
The Linux event viewer
How can you see the output of a process running in a detached container?
docker logs
docker exec -it
docker output
docker ls
docker run -it
You are authoring a Docker image to build the artifacts of a software application that you are developing, which constantly changes, requiring image rebuilds. The image requires that addition of a few dependencies, before the source code is built into an artifact. The source code is located within the build context, and copied into the image with COPY instruction. How should the Dockerfile be constructed?
There should be two RUN instructions, one for adding the dependencies, and one for building the artifacts from the source. The source should should be copied from the build context with the COPY instruction, which should be placed between two RUN instructions.
The commands from adding the dependencies, and performing the build, should be concatenated into a single RUN instruction, but should be the argument to an ONBUILD instruction. This way, we can get the benefits of the concatenated RUN instruction, but defer its execution until after the use of the COPY instruction.
The commands for adding the dependencies, and performing the build, should be concatenated into a single RUN instruction, in order to reduce image size and the number of layers. The source code should be copied with a COPY instruction, before the RUN instruction.
Which of the following is the most likely candidate for consideration for inclusion in a .dockerignore file in a build context?
app-1.1.7.jar
.git
nginx.conf
What will happen if a Docker image build is initiated, using a Dockerfile that has the following instruction:
COPY ../config /
The build will succeed, because the source file or directory will be copied to the build context before it's sent to the Docker deamon.
The build will fail, because the source of the COPY instruction is outside the build context.
It depends. If the Dockerfile is in a sub-directory of the build context, then the source for the COPY instruction is relative to the Dockerfile, will be in the build context, and the build will succeed.
Why use this more verbose Dockerfile?
WORKDIR /app
COPY *.csproj .
RUN dotnet restore
COPY . .
RUN dotnet publish
instead of this file:
WORKDIR /app
COPY . .
RUN dotnet restore; dotnet publish
Avoid package restoration when changing the project file.
Avoid compilation when changing package references only.
Avoid publishing when changing package references only.
Avoid package restore on every source code change.
What instruction is used to define a new stage in a Dockerfile?
RUN
COPY
FROM
STAGE
What does ! mean in a .dockerignore file?
An exception to the excludes.
Exclude all files.
Ab exception to the includes.
Include all files.
What can help avoid build cache invalidation?
Reduce the number of instructions in your Dockerfile.
Increase the number of instructions in your Dockerfile.
Add to the .dockerignore
You want to reduce the number of layers in an image so read operations have less to traverse. Which action can help reduce the number of layers in an image?
Switch the underlying of your Docker hosts to use storage are network (SAN) or network-attached storage (NAS) storage with native deduplication.
Edit the image's Dockerfile so that is has as few instructions as possible.
Use the OverlayFS (storage-driver=overlay) storage driver when starting the Docker daemon.
Use the Dockerfile COPY instruction instead of ADD.
What is accomplished by running the following command?
docker run -p 5000:5000 registry:latest
Only if the Docker Registry image has already been pulled will it be run, expositing port 5000.
The Docker Registry image will be pulled from Docker HUB using port 5000.
Docker Engine will run a "hot update" on the live Registry image.
The Docker Registry image will (if necessary) be pulled and then run, exposing port 5000.
How do you show all containers on a machine?
docker-machine ps -a
docker ps -a
docker rmi -p
docker showAllContainers -a
Which of the following docker commands will instantiate a new container and then execute that container's process in the background?
docker run -it <container_image> <process>
docker exec -it <container_image> <process>
docker exec <container_image> <process>
docker exec --detach <container_image> <process>
docker run --detach <container_image> <process>
Which of the following stops all running containers?
docker rmi (docker ps -q)
docker rm -f $(docker ps -q)
docker stop $(docker ps -q)
docker halt (docker ps -q)
Which of the following docker commands will instantiate a new container and immediately refocus the interactive command prompt to execute commands within that container?
docker run -it <container_image>
docker run <container_image> bash
docker run --detach <container_image>
docker exec <container_image> bash
What does the -d in docker run -d nginx do?
Runs an attached container.
Deletes the container when we stop the NGINX process.
Runs a container that will display output from the NGINX process in our console.
Runs a detached container.
How can I run another process inside a running container?
docker run
docker ps
docker start
docker exec
Which of the following docker commands will display a list of all running and stopped containers on a container host?
docker ps
docker ls -a
docker list
docker ls
docker ps -a
Which two docker container run flags are commonly used to create a container you can log-on to and interact with?
-telnet
-it
-alh
-ssh
Which of the following docker commands will stop all running containers and then delete all stopped containers on a container host?
docker rm * -f
docker prune
docker ps -a -q -f
docker rm $(docker ps -a -q) -f
What docker command executes software?
docker ps
docker pull
docker run
docker stop
How can we see all possible variables for a format?
--format '{{ json . }}'
--format '{{ printf . }}'
--format '{{ .List }}'
What does the index template function do?
Iterates over all elements in a list.
Provides faster lookups over keys in a table.
Select an item from an array.
You would prepare an image called hello-world for uploading to a local Docker Registry using which of the following commands?
docker -t hello-world localhost:5000/hello-world:latest
docker -tag 127.0.0.1/hello-world:latest
docker tag hello-world localhost/hello-world:latest
docker tag hello-world localhost:5000/hello-world:latest
Which is a tag?
A reference to a repository
A reference to a specific image in a registry.
A reference to a registry.
A reference to a specific image in a repository.
An image with an ID 69eab233e291 resides in a local repository called debian. It has two tags, jessie and latest. Another image, with ID 7787fd2ef68b, is created in the same repository, with the tag stretch. What will happen after the following command is executed: docker image tag debian:stretch debian:latest?
Both images remain in the repository; time image with ID 69eab233e291 has the single tag, jessie, whilst the image with ID 7787fd2ef68b, has the tags stretch and latest.
Both images remain, and because each image is a different entity with its own image ID, both images have the tag latest, in addition to the tag that is unique to each image.
The image with the ID 69eab233e291 is removed from the repository, because the image with ID 7787fd2ef68b has acquired its tag, latest.
What command can be run to download an image from Docker HUB.
docker rmi <image>
docker pull <image>
docker images
docker ps -a
What command can be used to deploy an image to a registry?
docker deploy
docker push
docker build
docker run
docker pull
