Q. What is the function of the 'docker pull' command?

  • (A) Pushes a Docker image to Docker Hub
  • (B) Downloads a Docker image from Docker Hub
  • (C) Starts a Docker container from an image
  • (D) Deletes a Docker image
πŸ’¬ Discuss
βœ… Correct Answer: (B) Downloads a Docker image from Docker Hub
Explanation: 'docker pull' is used to download a Docker image from a registry (such as Docker Hub).

Q. Which Docker command is used to stop and remove all containers?

  • (A) docker rm -f $(docker ps -a -q)
  • (B) docker stop --all
  • (C) docker container clean
  • (D) docker container remove --all
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker rm -f $(docker ps -a -q)
Explanation: 'docker rm -f $(docker ps -a -q)' stops and removes all containers on the system.

Q. What does the 'docker exec -it container_name bash' command do?

  • (A) Starts a container in interactive mode
  • (B) Executes a bash shell inside a running container
  • (C) Executes a command in the background
  • (D) Creates a new Docker container
πŸ’¬ Discuss
βœ… Correct Answer: (B) Executes a bash shell inside a running container
Explanation: 'docker exec -it container_name bash' opens an interactive bash shell inside a running container.

Q. Which of the following is a valid Docker Compose file version?

  • (A) version: 2
  • (B) version: 3
  • (C) version: 3.7
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above
Explanation: Docker Compose supports several file versions including version 2, 3, and 3.7.

Q. What is the default value for the 'restart' policy in Docker containers?

  • (A) always
  • (B) on-failure
  • (C) unless-stopped
  • (D) no
πŸ’¬ Discuss
βœ… Correct Answer: (D) no
Explanation: By default, the 'restart' policy for Docker containers is set to 'no', meaning they do not automatically restart.

Q. What is the purpose of the 'docker-compose pause' command?

  • (A) To pause all running services defined in a docker-compose.yml file
  • (B) To pause a specific container
  • (C) To pause Docker networks
  • (D) To pause Docker volumes
πŸ’¬ Discuss
βœ… Correct Answer: (A) To pause all running services defined in a docker-compose.yml file
Explanation: The 'docker-compose pause' command pauses all running services defined in the 'docker-compose.yml' file.

Q. Which command is used to view the Docker build cache?

  • (A) docker builder prune
  • (B) docker system df
  • (C) docker build cache
  • (D) docker image ls
πŸ’¬ Discuss
βœ… Correct Answer: (B) docker system df
Explanation: The 'docker system df' command displays information about Docker disk usage, including the build cache.

Q. What is the purpose of the 'docker-compose unpause' command?

  • (A) To unpause all paused services defined in a docker-compose.yml file
  • (B) To unpause a specific container
  • (C) To unpause Docker networks
  • (D) To unpause Docker volumes
πŸ’¬ Discuss
βœ… Correct Answer: (A) To unpause all paused services defined in a docker-compose.yml file
Explanation: The 'docker-compose unpause' command unpauses all paused services defined in the 'docker-compose.yml' file.

Q. Which command is used to remove all unused Docker networks?

  • (A) docker network prune
  • (B) docker system prune
  • (C) docker clean networks
  • (D) docker remove networks
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker network prune
Explanation: The 'docker network prune' command removes all unused Docker networks.

Q. What is the purpose of the 'docker-compose config --services' command?

  • (A) To list all services defined in a docker-compose.yml file
  • (B) To validate the docker-compose.yml file
  • (C) To display the configuration of services
  • (D) To list all containers
πŸ’¬ Discuss
βœ… Correct Answer: (A) To list all services defined in a docker-compose.yml file
Explanation: The 'docker-compose config --services' command lists all services defined in the 'docker-compose.yml' file.