Recall & Review
beginner
What command lets you open an interactive shell inside a running Docker container?
Use
docker exec -it <container_name_or_id> /bin/bash to open an interactive bash shell inside a running container.Click to reveal answer
beginner
What does the
-it option mean in docker exec -it?-i means interactive mode to keep STDIN open, and -t allocates a pseudo-TTY so you get a terminal interface.Click to reveal answer
beginner
How do you open a shell in a container that uses
sh instead of bash?Use
docker exec -it <container> /bin/sh because some containers have only sh shell.Click to reveal answer
intermediate
What is the difference between
docker exec and docker attach?docker exec runs a new command (like a shell) inside the container, while docker attach connects to the main process's input/output of the container.Click to reveal answer
beginner
Why might you want to open a shell inside a running container?
To inspect the container's file system, debug running processes, or manually run commands inside the container environment.
Click to reveal answer
Which command opens an interactive bash shell inside a running Docker container named 'webapp'?
✗ Incorrect
Use
docker exec -it webapp /bin/bash to open a new interactive shell inside the running container.What does the
-t option do in the command docker exec -it?✗ Incorrect
-t allocates a pseudo-terminal so you get a terminal interface.If a container does not have bash installed, which shell is commonly available?
✗ Incorrect
Most containers have
/bin/sh as a minimal shell.Which command connects to the main process's input/output of a running container?
✗ Incorrect
docker attach connects to the main process's input/output streams.Why is opening a shell inside a container useful?
✗ Incorrect
Opening a shell helps inspect files and debug inside the container.
Explain how to open an interactive shell inside a running Docker container and why you might do this.
Think about the command and the purpose of opening a shell.
You got /3 concepts.
Describe the difference between docker exec and docker attach commands.
Consider how each command interacts with the container.
You got /3 concepts.