Implementing DevOps Solutions and Practices using Cisco Platforms - Cisco Exam 300-910-DEVOPS Docker Command to Start Interactive Bash Shell in Container

Start an Interactive Bash Shell in a Docker Container | Cisco 300-910-DEVOPS Exam

Question

Which Docker command is used to start an interactive Bash shell in a running container named "test"?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

C.

The correct answer is C. docker exec -it test /bin/bash.

Explanation: Docker is a popular containerization platform that enables developers to package and deploy their applications in isolated containers. Containers are lightweight, portable, and can run on any system that supports Docker.

When a Docker container is started, it runs in the background as a separate process. However, it's possible to attach an interactive shell to the running container to execute commands and interact with its file system.

To start an interactive Bash shell in a running container named "test," we can use the docker exec command with the -it option. Here's what each part of the command does:

  • docker exec: This command is used to run a command inside a running container.
  • -it: This option starts an interactive terminal session in the container and allocates a pseudo-TTY.
  • test: This is the name of the running container.
  • /bin/bash: This is the command that we want to run inside the container, in this case, a Bash shell.

Therefore, the correct Docker command to start an interactive Bash shell in a running container named "test" is docker exec -it test /bin/bash. This will open a Bash shell prompt in the running container named "test," allowing the user to execute commands and interact with the container's file system.