5. You want to interactively debug a container named dbserver that is running but not responding correctly. Which sequence of commands lets you start a new shell session inside it without stopping the container?
hard
A. docker attach dbserver && exit
B. docker stop dbserver && docker run -it dbserver /bin/bash
C. docker build -t debug dbserver
D. docker exec -it dbserver /bin/bash
Solution
Step 1: Identify command to open shell in running container
docker exec -it runs a new interactive shell inside the running container without stopping it.
Step 2: Eliminate incorrect options
Stopping container loses state, attach connects to main process, build creates image not shell.
Final Answer:
docker exec -it dbserver /bin/bash -> Option D
Quick Check:
Exec runs shell inside running container [OK]
Hint: Use exec -it to open shell inside running container [OK]
Common Mistakes:
Stopping container before debugging loses state
Using attach instead of exec for shell access
Confusing build with container interaction
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.