Challenge - 5 Problems
Docker Exec Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
Output of docker exec with environment variable
What is the output of this command if the container named
webapp has an environment variable APP_MODE=production set?docker exec webapp printenv APP_MODEDocker
docker exec webapp printenv APP_MODEAttempts:
2 left
💡 Hint
The command prints the value of the environment variable inside the container.
✗ Incorrect
The
docker exec command runs printenv APP_MODE inside the webapp container, which outputs the value of the environment variable APP_MODE set to 'production'.💻 Command Output
intermediate1:30remaining
Effect of docker exec with interactive shell
What happens when you run this command?
docker exec -it mycontainer /bin/bashDocker
docker exec -it mycontainer /bin/bashAttempts:
2 left
💡 Hint
The flags -i and -t are used for interactive terminal sessions.
✗ Incorrect
The command opens an interactive bash shell inside the running container named mycontainer, allowing you to run commands inside it.
❓ Troubleshoot
advanced2:00remaining
Troubleshooting docker exec permission error
You run
docker exec mycontainer ls /root and get a permission denied error. What is the most likely cause?Attempts:
2 left
💡 Hint
Consider user permissions inside the container.
✗ Incorrect
The /root directory is usually accessible only by the root user. If docker exec runs as a non-root user, permission is denied.
🔀 Workflow
advanced2:30remaining
Correct sequence to update a file inside a running container
You want to update a configuration file inside a running container named
app. Which sequence of commands is correct?Attempts:
2 left
💡 Hint
Copy the file first, then move it, verify, and restart the service.
✗ Incorrect
First, copy the file into the container's temporary location, then move it to the correct path, verify the content, and finally restart the service to apply changes.
✅ Best Practice
expert2:00remaining
Best practice for running a command as root inside a container
Which docker exec command correctly runs
apt-get update as root inside a container named db?Attempts:
2 left
💡 Hint
The -u or --user flag must come before the container name.
✗ Incorrect
The correct syntax is
docker exec -u root db apt-get update. The -u flag specifies the user and must come before the container name.