








































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









































Question 1: Which component of Docker is responsible for building and managing containers? A. Docker Client B. Docker Engine C. Docker Registry D. Docker Hub Answer: B Explanation: The Docker Engine is the core component responsible for building and managing containers. Question 2: What is the primary difference between a virtual machine and a container? A. Containers use a full operating system while VMs share the host OS kernel. B. VMs virtualize the hardware while containers virtualize the OS. C. Containers require hypervisors, whereas VMs do not. D. VMs have lower overhead than containers. Answer: B Explanation: Virtual machines virtualize the underlying hardware and run separate OS instances, while containers share the host OS kernel, leading to lighter overhead. Question 3: Which of the following best describes Docker Images? A. Running processes B. Read-only templates C. Persistent storage D. Network configurations Answer: B Explanation: Docker Images are read-only templates used to create Docker containers. Question 4: What command is used to list all running Docker containers? A. docker images B. docker ps C. docker run D. docker inspect Answer: B Explanation: The command “docker ps” lists all currently running containers. Question 5: Which file is used to build a Docker image? A. Docker-compose.yml B. Dockerfile C. Imagefile D. Containerfile Answer: B Explanation: A Dockerfile contains instructions for building a Docker image. Question 6: What does the command “docker pull” do? A. Removes an image from the host B. Downloads an image from a registry
C. Pushes an image to Docker Hub D. Lists available images Answer: B Explanation: “docker pull” is used to download a Docker image from a remote registry. Question 7: Which statement correctly defines container caching in Docker? A. Containers automatically update their images B. Caching is used to reuse unchanged layers during builds C. Caching is not available in Docker builds D. It refers to storing container logs Answer: B Explanation: Docker caches unchanged layers during image builds to speed up the process. Question 8: How can you remove unused Docker images? A. docker prune images B. docker rmi $(docker images - q) C. docker image prune D. docker remove images Answer: C Explanation: The “docker image prune” command removes dangling images that are not in use. Question 9: What is the primary purpose of Docker Registries? A. To manage container logs B. To store and distribute Docker images C. To manage container networks D. To configure security settings Answer: B Explanation: Docker Registries, such as Docker Hub, are used to store and distribute Docker images. Question 10: Which command builds a Docker image from a Dockerfile? A. docker create B. docker run C. docker build D. docker compile Answer: C Explanation: The “docker build” command creates an image from the instructions in a Dockerfile. Question 11: What does “docker push” do? A. Uploads a container to a host B. Pushes changes to a Dockerfile C. Uploads an image to a Docker registry D. Sends a container to the background Answer: C Explanation: The “docker push” command is used to upload a Docker image to a registry. Question 12: Which Docker component acts as a command-line interface for interacting with the daemon?
Answer: B Explanation: The Bridge network is used to connect containers running on the same host. Question 18: Which command creates a new Docker network? A. docker network create B. docker create network C. docker net add D. docker network init Answer: A Explanation: The “docker network create” command is used to create a new network. Question 19: What is an overlay network used for in Docker Swarm? A. To connect containers on a single host B. To separate container logs C. To enable communication across multiple hosts D. To create a private registry Answer: C Explanation: Overlay networks are used in Swarm mode to allow containers running on different hosts to communicate securely. Question 20: How can you inspect the details of a Docker network? A. docker network details B. docker inspect network C. docker network inspect D. docker network show Answer: C Explanation: The “docker network inspect” command provides details about a specific Docker network. Question 21: Which of the following best describes Docker volumes? A. A method to store container logs B. A persistent storage mechanism for containers C. Temporary storage that is removed with the container D. A network configuration tool Answer: B Explanation: Docker volumes provide a persistent storage mechanism independent of container lifecycles. Question 22: What is a bind mount in Docker? A. A Docker storage driver B. A way to mount host files or directories into a container C. A method for container networking D. A backup mechanism for volumes Answer: B Explanation: Bind mounts allow you to mount a file or directory from the host into a container. Question 23: Which command is used to list all Docker volumes? A. docker volume list
B. docker volume show C. docker volume inspect D. docker volume ls Answer: D Explanation: The “docker volume ls” command lists all volumes managed by Docker. Question 24: What is the purpose of Docker Volume Drivers? A. To manage container execution B. To enable persistent storage on different platforms C. To manage container networking D. To update Docker images automatically Answer: B Explanation: Docker Volume Drivers allow integration with external storage systems and platforms for persistent storage. Question 25: Which of the following is a best practice for securing Docker containers? A. Running containers as root B. Using outdated images C. Minimizing container privileges D. Disabling security scanning Answer: C Explanation: Minimizing container privileges (using non-root users, least privilege) is a best practice to enhance container security. Question 26: What does Docker Content Trust (DCT) provide? A. Automated container scaling B. Image signing and verification C. Centralized logging D. Network configuration Answer: B Explanation: Docker Content Trust ensures the authenticity and integrity of Docker images through signing and verification. Question 27: Which security tool is commonly used for vulnerability scanning in Docker images? A. Docker Compose B. Docker Swarm C. Clair D. Docker Hub Answer: C Explanation: Clair is a popular tool for scanning Docker images for vulnerabilities. Question 28: What are seccomp profiles used for in Docker? A. Managing container storage B. Restricting system calls available to containers C. Configuring container networking D. Scaling services in a Swarm Answer: B
Explanation: “docker-compose down” stops and removes containers, networks, and other resources created by docker-compose up. Question 34: Which orchestration mode in Docker allows for clustering of multiple Docker hosts? A. Docker Compose B. Docker Swarm C. Docker Hub D. Docker Client Answer: B Explanation: Docker Swarm mode enables clustering of multiple Docker hosts into a single virtual system. Question 35: What is the first step when initializing a Docker Swarm cluster? A. Joining nodes B. Running docker swarm init C. Running docker-compose up D. Configuring overlay networks Answer: B Explanation: To initialize a Docker Swarm, you start with “docker swarm init” on the manager node. Question 36: In Docker Swarm, which command is used to add a new worker node? A. docker swarm join B. docker node add C. docker join swarm D. docker swarm connect Answer: A Explanation: Worker nodes join a swarm by executing “docker swarm join” with the token provided by the manager. Question 37: How are rolling updates achieved in Docker Swarm? A. By restarting all containers simultaneously B. Through the “docker service update” command with update parameters C. By removing the service and redeploying D. Using Docker Compose scaling Answer: B Explanation: Rolling updates in Docker Swarm are performed using “docker service update” with proper update configurations. Question 38: Which type of Docker network is commonly used for container communication within a swarm? A. Bridge network B. Host network C. Overlay network D. None network Answer: C Explanation: Overlay networks are typically used in Docker Swarm mode to enable secure communication across hosts.
Question 39: What role does service discovery play in Docker Swarm? A. It identifies container vulnerabilities B. It allows containers to find and communicate with each other C. It monitors container performance D. It schedules container restarts Answer: B Explanation: Service discovery in Docker Swarm helps containers locate and communicate with one another within the cluster. Question 40: Which command displays logs for a Docker container? A. docker logs B. docker show logs C. docker inspect logs D. docker container logs Answer: A Explanation: The “docker logs” command is used to display logs from a specified container. Question 41: Which logging driver sends container logs to syslog? A. json-file B. syslog C. journald D. fluentd Answer: B Explanation: The syslog logging driver sends container logs to the system syslog. Question 42: How can centralized logging be achieved with Docker? A. By using only local log files B. Through external log management systems integrated with Docker C. By using docker-compose logs D. By scaling containers Answer: B Explanation: Centralized logging is achieved by integrating Docker logs with external log management and monitoring systems. Question 43: Which tool is commonly used for monitoring Docker container performance? A. Docker Hub B. Prometheus C. Dockerfile Inspector D. Docker Compose Answer: B Explanation: Prometheus is widely used for monitoring container performance and collecting metrics. Question 44: What is the benefit of setting up alerts for Docker containers? A. To disable container networking B. To proactively detect and address issues C. To automatically build images D. To create container backups
Question 50: Which practice is considered a best practice for Docker in CI/CD workflows? A. Keeping container images large and complex B. Hard-coding environment variables in the image C. Using lightweight base images and parameterizing configuration D. Disabling automated testing Answer: C Explanation: Lightweight base images and external configuration make containers more efficient and flexible in CI/CD workflows. Question 51: Which command is used to inspect a running container’s configuration? A. docker config B. docker inspect C. docker show D. docker details Answer: B Explanation: “docker inspect” provides detailed information about a container’s configuration and state. Question 52: What is the purpose of the “docker exec” command? A. To stop a running container B. To run a command inside an active container C. To update the Docker engine D. To inspect container logs Answer: B Explanation: The “docker exec” command lets you run commands inside a running container, which is useful for troubleshooting. Question 53: What does a “restart policy” do in Docker? A. Controls container logging B. Specifies conditions under which a container should automatically restart C. Defines container network settings D. Sets up image caching Answer: B Explanation: Restart policies ensure that containers are automatically restarted if they exit unexpectedly. Question 54: Which of the following is an example of handling container crashes effectively? A. Disabling container logging B. Setting an appropriate restart policy C. Removing all error messages D. Disabling container health checks Answer: B Explanation: A proper restart policy ensures that containers are automatically restarted in the event of a crash. Question 55: Which Docker networking type should you use for a container that needs to share the host’s network stack? A. Bridge
B. Host C. Overlay D. None Answer: B Explanation: The host network mode allows the container to share the host’s network stack directly. Question 56: What is the benefit of using custom DNS settings in Docker? A. It speeds up container start times B. It allows containers to resolve custom hostnames C. It increases container storage capacity D. It disables container logging Answer: B Explanation: Custom DNS settings allow containers to resolve hostnames that may not be available through default DNS resolution. Question 57: Which command is used to remove a Docker container? A. docker rm B. docker remove C. docker kill D. docker delete Answer: A Explanation: The “docker rm” command is used to remove one or more Docker containers. Question 58: In Docker security, what is the role of user namespaces? A. To separate container file systems B. To map container users to different host users, reducing privileges C. To manage container logs D. To enforce network policies Answer: B Explanation: User namespaces map container users to less-privileged host users, improving security by isolating user permissions. Question 59: What is the advantage of using a private Docker registry? A. It automatically scales containers B. It provides secure, internal storage for Docker images C. It manages container logs D. It reduces container image size Answer: B Explanation: A private registry offers a secure way to store and manage Docker images internally. Question 60: Which statement best describes the function of a Dockerfile instruction “RUN”? A. It defines environment variables B. It executes commands during the image build C. It specifies the base image D. It exposes ports to the host Answer: B
Question 66: In Docker, what is the primary purpose of tmpfs mounts? A. Persistent storage B. Temporary storage in memory C. Network configuration D. Log management Answer: B Explanation: Tmpfs mounts store data in the container’s memory, offering fast temporary storage that does not persist. Question 67: Which Docker command allows you to view active networks? A. docker network ls B. docker network show C. docker network view D. docker ls network Answer: A Explanation: “docker network ls” lists all networks available in the Docker environment. Question 68: What is one of the key benefits of using Docker Compose over running individual docker run commands? A. It requires no configuration files B. It enables definition and orchestration of multi-container applications in a single file C. It eliminates the need for Dockerfiles D. It automatically scales containers Answer: B Explanation: Docker Compose simplifies the management of multi-container applications through a single configuration file. Question 69: Which of the following is a characteristic of Docker Swarm mode? A. It requires external orchestration tools B. It allows for built-in clustering and scaling of containers C. It is used solely for development purposes D. It does not support service discovery Answer: B Explanation: Docker Swarm mode offers built-in clustering, scaling, and service discovery for managing containers across hosts. Question 70: Which component in Docker Swarm is responsible for scheduling tasks on nodes? A. Docker Client B. Docker Daemon C. Swarm Manager D. Docker Registry Answer: C Explanation: The Swarm Manager schedules tasks on worker nodes within the Docker Swarm cluster. Question 71: What is the primary purpose of health checks in Docker Swarm services? A. To update container images B. To monitor and ensure the proper functioning of services
C. To scale services automatically D. To manage container logs Answer: B Explanation: Health checks ensure that the services are running as expected and can trigger restarts or alerts if issues occur. Question 72: Which command is used to update a Docker service in a swarm? A. docker service update B. docker swarm update C. docker service upgrade D. docker update service Answer: A Explanation: The “docker service update” command is used to modify parameters of a running service in a Docker Swarm. Question 73: What does the term “container lifecycle” refer to? A. The steps involved in container networking B. The process of building, running, pausing, and stopping a container C. The versioning of container images D. The network protocols used by containers Answer: B Explanation: Container lifecycle encompasses all stages from creation to termination, including running and stopping. Question 74: How can you scale a Docker service in Swarm mode? A. By running multiple docker run commands B. By using docker service scale C. By updating the Dockerfile D. By modifying the container’s memory settings Answer: B Explanation: The “docker service scale” command adjusts the number of replicas for a given service. Question 75: Which command is used to check the status of nodes in a Docker Swarm cluster? A. docker node ls B. docker swarm status C. docker node status D. docker swarm ls Answer: A Explanation: “docker node ls” lists all nodes in a Docker Swarm cluster and displays their status. Question 76: What is the role of a Docker API in container management? A. It provides a graphical interface for Docker B. It allows programmatic access to Docker functions C. It stores container images D. It secures the host network Answer: B Explanation: The Docker API provides programmatic access to control and manage Docker operations.
Question 82: What does the “docker run” command do? A. Builds a Docker image B. Runs a command inside a running container C. Creates and starts a new container D. Stops a container Answer: C Explanation: “docker run” creates and starts a new container from a specified image. Question 83: Which flag is used with “docker run” to run a container in detached mode? A. --detached B. - d C. --background D. - b Answer: B Explanation: The “-d” flag runs the container in detached mode, meaning it runs in the background. Question 84: What is the effect of the “EXPOSE” instruction in a Dockerfile? A. It publishes ports automatically B. It documents which ports the container will listen on at runtime C. It opens firewall ports on the host D. It exposes container logs Answer: B Explanation: The “EXPOSE” instruction is used for documentation purposes and does not actually publish ports to the host. Question 85: Which of the following is true about container networking performance? A. It is not affected by the chosen network driver B. Overlay networks typically have lower performance than bridge networks due to additional encapsulation C. Host networks always offer the lowest latency D. Docker networking does not support encryption Answer: B Explanation: Overlay networks add encapsulation overhead, which can reduce performance compared to bridge networks. Question 86: What is the benefit of using persistent storage in Docker containers? A. It ensures data is lost when containers stop B. It allows data to persist even after the container is removed C. It increases container memory D. It optimizes container networking Answer: B Explanation: Persistent storage via volumes ensures data remains available even if the container is removed. Question 87: Which Docker storage type is best for temporary data that should be fast but non- persistent? A. Volumes
B. Bind mounts C. Tmpfs D. External storage Answer: C Explanation: Tmpfs mounts store data in memory and are ideal for temporary storage that does not need persistence. Question 88: What command would you use to inspect a Docker volume’s details? A. docker volume inspect B. docker inspect volume C. docker volume details D. docker volume show Answer: A Explanation: “docker volume inspect” provides detailed information about a specified volume. Question 89: Which security mechanism in Docker can be used to limit the system calls available to a container? A. User namespaces B. Seccomp profiles C. Docker Content Trust D. Volume drivers Answer: B Explanation: Seccomp profiles limit the system calls that containers can execute, thereby improving security. Question 90: How does AppArmor enhance container security in Docker? A. By managing container networking B. By restricting the actions a container process can perform based on profiles C. By encrypting container data D. By caching container logs Answer: B Explanation: AppArmor restricts container processes by enforcing security policies defined in profiles. Question 91: What is the purpose of a Docker Compose file’s “volumes” section? A. To define environment variables B. To manage container image layers C. To map host directories or volumes to container directories D. To configure network settings Answer: C Explanation: The “volumes” section in a Compose file is used to map host directories or named volumes into containers. Question 92: Which command can be used to remove unused containers, networks, images, and volumes in Docker? A. docker system prune B. docker clean C. docker remove all
Answer: C Explanation: You can override the default CMD by providing a different command when using “docker run.” Question 98: Which instruction in a Dockerfile is used to copy files from the host into the container image? A. ADD B. COPY C. MOVE D. INSTALL Answer: B Explanation: The “COPY” instruction copies files from the host into the Docker image. (Note: ADD also works but COPY is preferred for its simplicity.) Question 99: Which of the following is considered a best practice when managing Docker images? A. Keeping unused images on the host B. Regularly pruning unused images and containers C. Running containers with root privileges D. Hard-coding configurations into images Answer: B Explanation: Regularly pruning unused images and containers helps maintain a clean and efficient Docker environment. Question 100: In the context of Docker, what does “docker-compose scale” achieve? A. It increases the size of container images B. It scales the number of container instances for a service C. It scales the Docker engine performance D. It scales the Dockerfile instructions Answer: B Explanation: “docker-compose scale” allows you to specify the number of container instances to run for a given service. Question 101: Which networking mode in Docker bypasses the container network stack and uses the host network directly? A. Bridge B. Host C. Overlay D. None Answer: B Explanation: The host networking mode allows the container to share the host’s network stack directly, reducing network isolation. Question 102: What is one of the security risks in containerized environments? A. Over-provisioning of resources B. Unauthorized access due to shared kernel C. High latency D. Slow image builds
Answer: B Explanation: Containers share the host kernel, so a vulnerability in the kernel or container isolation may lead to unauthorized access. Question 103: Which Docker command is used to stop a running container? A. docker kill B. docker pause C. docker stop D. docker terminate Answer: C Explanation: The “docker stop” command gracefully stops a running container. Question 104: How can you check the version of Docker installed on your system? A. docker info --version B. docker --version C. docker version D. Both B and C Answer: D Explanation: Both “docker --version” and “docker version” can be used to check the installed Docker version. Question 105: What does the term “orchestration” refer to in Docker Swarm? A. Tuning container performance B. Coordinating multiple containers and services C. Securing container images D. Managing Docker volumes Answer: B Explanation: Orchestration involves managing and coordinating multiple containers and services, which is a key feature of Docker Swarm. Question 106: Which file in Docker Compose defines the multi-container application configuration? A. docker-compose.yaml B. Dockerfile C. compose.json D. swarm.yml Answer: A Explanation: The docker-compose.yaml (or docker-compose.yml) file defines the configuration for multi- container applications. Question 107: Which command removes all stopped containers in Docker? A. docker container rm $(docker ps - a - q) B. docker prune containers C. docker rm - f all D. docker system prune --all Answer: D Explanation: “docker system prune --all” will remove all stopped containers, unused networks, images, and optionally volumes.