Docker Quiz -_Hard Level (50 Questions)
Docker Quiz -_Hard Level (50 Questions)
LinkedIn: https://www.linkedin.com/in/shaikkhadarbasha/
Website: https://newsletter.codetuts.in/
You want to limit a container's memory usage to 512MB to avoid consuming all available
system memory. Which option will you use in the docker run command?
1. --memory=512mb
2. --limit-memory=512mb
3. --mem-limit=512m
4. --resource-limit=512m
Question 2:
You need to run a container in detached mode while naming it web_app. Which command
achieves this?
Question 3:
Question 4:
You want to see the real-time resource usage (CPU, memory, etc.) of running containers.
Which command will you use?
1. docker info
2. docker stats
3. docker ps -a
4. docker usage
Author: Khadar Basha SHAIK
LinkedIn: https://www.linkedin.com/in/shaikkhadarbasha/
Website: https://newsletter.codetuts.in/
Question 5:
How can you forcefully stop a container that isn’t responding to the docker stop
command?
1. docker terminate
2. docker kill
3. docker container delete
4. docker force-stop
How can you rebuild a Docker image without using cached layers?
Question 7:
Which of the following reduces Docker image size during the build process?
Question 8:
Question 9:
Question 10:
Section 3: Networking
Question 11:
You need two containers to communicate with each other. What is the best approach?
Question 12:
Question 13:
What is the default network driver created by Docker for new containers?
1. bridge
2. host
3. none
4. overlay
Question 14:
Question 15:
Which Docker network type allows containers on multiple hosts to communicate with each
other?
1. bridge
2. overlay
3. host
4. none
Question 17:
What happens to the data in a container’s anonymous volume after the container is
removed?
Question 18:
Question 19:
You want to backup the contents of a named volume. Which command should you use?
Question 20:
1. Bind mounts are managed by Docker, while volumes are tied to host paths
2. Volumes are managed by Docker, while bind mounts use host paths
3. Bind mounts are always persistent, but volumes are not
4. Volumes are more secure than bind mounts
Section 5: Security
Question 21:
What is the best practice for securing sensitive data used by containers?
Question 22:
1. Use --privileged=false
2. Use the --user flag to specify a non-root user
3. Run as root but restrict file permissions
4. Use Docker's default configuration
Question 23:
Question 24:
Question 25:
Question 27:
Question 28:
Question 29:
Question 30:
Section 7: Performance
Question 31:
How do you monitor a container’s CPU and memory usage over time?
Question 32:
What is the effect of using the --cpu-shares flag when starting a container?
Question 33:
Question 34:
Which of the following is the best practice to reduce container startup time?
Question 35:
Section 8: Troubleshooting
Question 36:
1. docker ps --logs
2. docker logs <container-id>
3. docker inspect logs <container-id>
4. docker container logs --failed
Question 37:
What does the error “no space left on device” indicate in Docker?
Question 38:
Question 39:
How can you see all events (start, stop, etc.) related to Docker containers?
1. docker events
2. docker history
3. docker activity
4. docker info
Question 40:
You suspect a container process is consuming excessive resources. How do you check
which processes are running inside it?
Which of the following is required to enable inter-host communication for Docker containers?
Question 42:
Question 43:
Author: Khadar Basha SHAIK
LinkedIn: https://www.linkedin.com/in/shaikkhadarbasha/
Website: https://newsletter.codetuts.in/
Question 44:
How can you verify connectivity between two containers on the same network?
How do you remove all stopped containers, unused networks, and dangling images?
1. docker cleanup
2. docker system prune
3. docker prune --all
4. docker remove --all
Question 46:
Question 47:
Question 48:
1. Exclude files from being copied during the image build process
2. Ignore container logs during runtime
3. Prevent specific containers from being started
4. Specify ignored images
Question 49:
Question 50:
Answer: --memory=512mb
Explanation: The --memory flag in the docker run command allows you to set a
memory limit for a container.
Question 2:
Question 3:
Question 4:
Question 5:
Question 7:
Author: Khadar Basha SHAIK
LinkedIn: https://www.linkedin.com/in/shaikkhadarbasha/
Website: https://newsletter.codetuts.in/
Question 8:
Question 9:
Question 10:
Section 3: Networking
Question 11:
Question 12:
Question 13:
Answer: bridge
Explanation: The default network for new containers is the bridge network unless
specified otherwise.
Question 14:
Question 15:
Answer: overlay
Explanation: The overlay network driver enables multi-host communication, suitable for
Swarm or Kubernetes.
Question 17:
Question 18:
Question 19:
Answer:
Explanation: This command mounts the volume, copies its contents into a tar archive, and
saves it to the current directory.
Question 20:
Answer: Volumes are managed by Docker, while bind mounts use host paths
Explanation: Volumes are Docker-managed and portable, whereas bind mounts directly
map host directories.
Section 5: Security
Author: Khadar Basha SHAIK
LinkedIn: https://www.linkedin.com/in/shaikkhadarbasha/
Website: https://newsletter.codetuts.in/
Question 21:
Question 22:
Question 23:
Question 24:
Question 25:
Answer: To securely store sensitive data like passwords and API keys
Explanation: Docker secrets are encrypted at rest and only exposed to containers that
require them.
Section 6: Orchestration
Question 26:
Question 27:
Question 28:
Question 29:
Question 30:
Answer: Swarm supports scaling and orchestration, but Compose does not
Explanation: Compose is ideal for local environments, while Swarm enables service
scaling and orchestration.
Section 7: Performance
Question 31:
Question 32:
Question 33:
Question 34:
Question 35:
Section 8: Troubleshooting
Question 36:
Author: Khadar Basha SHAIK
LinkedIn: https://www.linkedin.com/in/shaikkhadarbasha/
Website: https://newsletter.codetuts.in/
Question 37:
Answer: A volume or the Docker storage layer has run out of disk space
Explanation: The error indicates insufficient disk space for Docker storage.
Question 38:
Question 39:
Question 40:
Question 42:
Question 43:
Question 44:
Author: Khadar Basha SHAIK
LinkedIn: https://www.linkedin.com/in/shaikkhadarbasha/
Website: https://newsletter.codetuts.in/
Answer: Use docker inspect to check IPs and test with ping
Explanation: Inspect the container network settings and verify connectivity using ping.
Question 46:
Question 47:
Question 48:
Answer: Exclude files from being copied during the image build process
Explanation: .dockerignore prevents unnecessary files from being included in the
image build context.
Question 49:
Question 50: