Implementing DevOps Solutions and Practices Using Cisco Platforms (DEVOPS) — Question 14
Which Docker command is used to start an interactive Bash shell in a running container named "test"?
Answer options
- A. docker attach -it test /bin/bash
- B. docker run -it test /bin/bash
- C. docker exec -it test /bin/bash
- D. docker run test /bin/bash
Correct answer: C
Explanation
The correct command is 'docker exec -it test /bin/bash' because it allows execution of a command in an already running container. 'docker attach' connects to the running container's console but doesn't start a new Bash shell, while 'docker run' creates a new container rather than accessing an existing one.