πŸ“Š Docker
Q. What is the purpose of the 'docker exec' command?
  • (A) To execute a command inside a running container
  • (B) To create a new Docker container
  • (C) To remove a container
  • (D) To build a Docker image
πŸ’¬ Discuss
βœ… Correct Answer: (A) To execute a command inside a running container

Explanation: The 'docker exec' command is used to execute a command inside a running Docker container.

πŸ“Š Docker
Q. What is the difference between 'docker stop' and 'docker kill'?
  • (A) docker stop terminates containers immediately, docker kill gracefully stops them
  • (B) docker stop sends a SIGTERM signal, docker kill sends SIGKILL
  • (C) docker stop is for containers, docker kill is for images
  • (D) docker stop is a safer method, docker kill is faster
πŸ’¬ Discuss
βœ… Correct Answer: (B) docker stop sends a SIGTERM signal, docker kill sends SIGKILL

Explanation: 'docker stop' sends a SIGTERM signal to gracefully stop a container, while 'docker kill' sends a SIGKILL signal to forcefully stop it.

πŸ“Š Docker
Q. Which of the following is a valid option for the 'docker run' command?
  • (A) -name
  • (B) -d
  • (C) --execute
  • (D) --detach
πŸ’¬ Discuss
βœ… Correct Answer: (B) -d

Explanation: The '-d' flag is used with 'docker run' to run the container in detached mode.

πŸ“Š Docker
Q. What is the default network driver used by Docker?
  • (A) bridge
  • (B) host
  • (C) overlay
  • (D) macvlan
πŸ’¬ Discuss
βœ… Correct Answer: (A) bridge

Explanation: The default network driver used by Docker is 'bridge', which creates a private internal network.

πŸ“Š Docker
Q. Which of the following commands creates a Docker container from an image?
  • (A) docker run
  • (B) docker create
  • (C) docker build
  • (D) docker start
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker run

Explanation: The 'docker run' command is used to create and start a container from an image.

πŸ“Š Docker
Q. What command would you use to remove a Docker image?
  • (A) docker rm image_name
  • (B) docker rmi image_name
  • (C) docker image rm image_name
  • (D) docker remove image_name
πŸ’¬ Discuss
βœ… Correct Answer: (B) docker rmi image_name

Explanation: The 'docker rmi' command is used to remove a Docker image from the local machine.

πŸ“Š Docker
Q. Which command is used to build a Docker image from a Dockerfile?
  • (A) docker create
  • (B) docker build
  • (C) docker run
  • (D) docker compose
πŸ’¬ Discuss
βœ… Correct Answer: (B) docker build

Explanation: The 'docker build' command is used to build a Docker image from a Dockerfile and a context (usually the current directory).

πŸ“Š Docker
Q. What is the default network driver used by Docker?
  • (A) host
  • (B) bridge
  • (C) overlay
  • (D) macvlan
πŸ’¬ Discuss
βœ… Correct Answer: (B) bridge

Explanation: The default network driver in Docker is 'bridge', which creates a private internal network for containers to communicate.

πŸ“Š Docker
Q. Which command is used to list all running Docker containers?
  • (A) docker ps
  • (B) docker ls
  • (C) docker list
  • (D) docker containers
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker ps

Explanation: The 'docker ps' command lists all running containers. To list all containers (including stopped ones), use 'docker ps -a'.

πŸ“Š Docker
Q. What is the purpose of a Dockerfile?
  • (A) To define the runtime environment for a container
  • (B) To manage Docker volumes
  • (C) To configure Docker networks
  • (D) To monitor Docker containers
πŸ’¬ Discuss
βœ… Correct Answer: (A) To define the runtime environment for a container

Explanation: A Dockerfile is a text document that contains instructions to build a Docker image, defining the runtime environment for a container.