Recall & Review
beginner
What does the
docker exec command do?It runs a new command inside a running Docker container without starting a new container.
Click to reveal answer
beginner
How do you run an interactive shell inside a running container named
webapp?Use
docker exec -it webapp /bin/bash to open an interactive bash shell inside the container.Click to reveal answer
intermediate
What does the
-it option mean in docker exec?-i keeps STDIN open, and -t allocates a pseudo-TTY, allowing interactive commands.Click to reveal answer
beginner
Can you use
docker exec to run commands in a stopped container?No, the container must be running to use
docker exec.Click to reveal answer
beginner
How do you run a one-time command like
ls /app inside a container named backend?Run
docker exec backend ls /app to list the contents of the /app directory inside the container.Click to reveal answer
What is required before you can use
docker exec to run a command inside a container?✗ Incorrect
You can only run commands inside containers that are currently running.
Which option allows you to run an interactive shell inside a container?
✗ Incorrect
The
-it option keeps input open and allocates a terminal for interaction.What happens if you run
docker exec without specifying a command?✗ Incorrect
You must specify a command to run inside the container with
docker exec.How do you run a command inside a container named
db to check the current directory?✗ Incorrect
docker exec db pwd runs the pwd command inside the running container named db.Which of these commands opens an interactive shell inside a container named
app?✗ Incorrect
Using
docker exec -it app /bin/sh opens an interactive shell inside the running container.Explain how to use
docker exec to run an interactive shell inside a running container.Think about how to keep input open and allocate a terminal.
You got /4 concepts.
Describe the limitations of
docker exec regarding container state and command execution.Consider when and how <code>docker exec</code> works.
You got /4 concepts.