0
0
Dockerdevops~20 mins

Bind mounts for development in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Bind Mount Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Bind mount behavior with file changes
You run a Docker container with this command:
docker run -it -v /host/app:/container/app ubuntu bash

If you edit a file inside /host/app on your host machine, what happens inside the container's /container/app directory?
AThe container deletes the file automatically when the host file changes.
BThe file inside the container does not change until the container is restarted.
CThe container creates a copy of the file and changes do not sync back to the host.
DThe file inside the container updates immediately to match the host file changes.
Attempts:
2 left
💡 Hint
Think about what a bind mount does: it links host and container directories directly.
Configuration
intermediate
2:00remaining
Correct bind mount syntax in docker-compose
Which docker-compose service configuration correctly sets a bind mount from the host ./src directory to the container /app directory?
A
volumes:
  - /app:./src
B
volumes:
  - /src:/app
C
volumes:
  - ./src:/app
D
volumes:
  - app:/src
Attempts:
2 left
💡 Hint
Remember the format is host_path:container_path.
Troubleshoot
advanced
2:00remaining
Why are file changes not visible inside container?
You set up a bind mount with:
docker run -v /home/user/project:/app myimage

But when you edit files in /home/user/project on the host, the container does not see the changes. What is the most likely cause?
AThe bind mount path on the host is incorrect or does not exist.
BThe container's /app directory is read-only and cannot update.
CDocker does not support bind mounts on Linux hosts.
DThe container is using a cached image and needs to be rebuilt.
Attempts:
2 left
💡 Hint
Check the exact path on your host machine carefully.
🔀 Workflow
advanced
2:00remaining
Using bind mounts for live code development
You want to develop a Node.js app inside a Docker container and see code changes immediately without rebuilding the image. Which workflow is best?
ABuild the image once, then use a bind mount to link your local code folder to the container's app folder.
BRebuild the Docker image every time you change code, then restart the container.
CCopy code into the container at runtime using docker cp after each change.
DUse a Docker volume instead of a bind mount for live code syncing.
Attempts:
2 left
💡 Hint
Think about how to avoid rebuilding the image for every code change.
Best Practice
expert
2:00remaining
Security considerations with bind mounts
Which is the safest practice when using bind mounts in Docker for development?
ABind mount the entire host root directory to the container for full access.
BBind mount only the specific project directory needed by the container.
CAvoid using bind mounts and copy files into the container instead.
DRun the container as root user to avoid permission issues with bind mounts.
Attempts:
2 left
💡 Hint
Think about limiting access to only what is necessary.