Skip to content

Questionnaire

DockerLabs Banner


Docker Questionnaire

Think you got it all?

Test yourself: pick an answer for every question, then click Answer to check yourself - the same way the Tasks reveal their solutions.


Question 1: Which docker command will run a container in the background?
a. docker run -b alpine
b. docker run -d alpine
c. docker run -it alpine /bin/bash
d. docker run -it -d=false alpine
Answer

b. docker run -d alpine - -d runs the container in detached (background) mode.


Question 2: Which docker command will remove a docker container?
a. docker rm
b. docker rmi
c. docker stop
d. docker remove
Answer

a. docker rm - docker rmi removes an image, docker stop only stops the container.


Question 3: Which docker command will “download” an image from the Registry?
a. docker install
b. docker pull
c. docker download
d. docker exec
Answer

b. docker pull - pulls an image from a registry (Docker Hub or your own).


Question 4: Which docker command will display information about the docker image?
a. docker stats
b. docker summary
c. docker inspect
d. docker info
Answer

c. docker inspect - returns low-level information (JSON) about images and containers.


Question 5: Which file system does Docker use to build up images?
a. NTFS
b. BTRFS
c. ZFS
d. AUFS
Answer

d. AUFS - Docker’s classic layered storage driver (union file system).


Question 6: Which command is used for building a Docker image?
a. run
b. cp
c. build
d. commit
Answer

c. docker build - builds an image from a Dockerfile (docker commit snapshots a container).


Question 7: What are the steps for the Docker container life cycle?
a. Build, Run, Stop
b. Build, Run, Exit
c. Created, Started, Exited
d. Run, Pull, Started, Exited
Answer

c. Created, Started, Exited - the states docker ps -a reports for a container.


Question 8: What does the volume (-v) parameter do in a docker run command?
a. Create folder on the host
b. Create volume in the container
c. Volume is not a valid flag
d. Bind filesystem between the host and the container
Answer

d. Bind filesystem between the host and the container - e.g. -v /data:/container-data.


Question 9: Which Dockerfile command defines which port the app is listening on?
a. OPEN
b. EXPOSE
c. LISTEN
d. ENTRYPOINT
Answer

b. EXPOSE - documents (and signals) the port the container listens on.


Question 10: Which Dockerfile command(s) add files to the image? (can be more than 1)
a. RUN
b. COPY
c. ADD
d. FROM
Answer

b & c - COPY and ADD - both copy files into the image; ADD can also extract archives.


Question 11: Which Dockerfile command will not add new layers to the image?
a. RUN
b. COPY
c. ENV
d. FROM
Answer

c. ENV - it only sets environment metadata, no file content is added.


Question 12: Which Dockerfile command changes the current directory?
a. RUN
b. CD
c. SET
d. WORKDIR
Answer

d. WORKDIR - sets the working directory for the instructions that follow (there is no CD).


Question 13: Which Dockerfile command is used for executing a script when the container starts?
a. EXPOSE
b. RUN
c. CMD
d. ENTRYPOINT
Answer

d. ENTRYPOINT - runs at container start (CMD provides default arguments).


Question 14: What is Docker Compose? What can it be used for?
a. Define docker image content
b. A tool that lets you define multiple containers and their configurations via a YAML or JSON file
c. Change an existing container and inject new content
d. Optimization tools for production containers
Answer

b - Compose describes and runs a multi-container application stack (see Docker Compose Labs).


Question 15: What are the various states that a Docker container can be in at any given point in time?
a. Running
b. Paused
c. Restarting
d. Exited
Answer

All of the above - containers can be Running, Paused, Restarting or Exited.


Question 16: How to execute a command on a running container?
a. docker exec -it <container id> <command>
b. docker start -it <container id> <command>
c. docker image -it <container id> <command>
d. docker load -it <container id> <command>
Answer

a. docker exec -it <container id> <command> - runs a command inside a running container.


Question 17: How do you get the status of a Docker container?
a. docker ps
b. docker info
c. docker inspect
d. docker status
Answer

a. docker ps - lists containers and their status (docker ps -a includes stopped ones).


Question 18: What is the difference between the COPY and ADD commands in a Dockerfile?
a. There is no difference, ADD is the old (backward compatibility) command
b. They are the same, no difference
c. ADD will copy and extract files (zip, tar etc), COPY will only copy the files
d. COPY is for copying files, ADD is for adding an existing image
Answer

c - ADD copies and extracts local tar archives / fetches remote URLs; prefer COPY for plain files.


Question 19: In a Dockerfile, which instruction is used for setting the base image for the container?
a. ADD
b. FROM
c. ENTRYPOINT
d. BASE
Answer

b. FROM - every Dockerfile (stage) starts with a base image.


Question 20: EXPOSE in docker-compose will do the following?
a. Open and listen on a given port when the container is running
b. Allow users to open this port if they wish to
c. Document which port the service (application) will accept network traffic on
d. Create a secure network between the application to the host
Answer

c - EXPOSE is documentation; opening ports to the host is done with ports: (-p).


Happy quizzing! 🐳