bind mount
Mounting a folder from the host directly into a container, so both see the same files.
Mounting sensitive host paths lets a container read or change the host.
In more detail
Useful in development: mount your source code and the container sees each edit immediately, which is what hot reloading relies on. Files keep their host owner and permissions, which can surprise a container running as a non-root user. Never bind-mount sensitive host paths such as / or the Docker socket into containers you do not fully trust.
Examples
docker run --rm -v "$PWD":/app -w /app python:3.12-alpine python app.pydocker run --rm -v "$PWD:/app" m02l01-client python producer.pyRelated terms
- volume — Storage managed by Docker that lives outside any container, so data survives when the container is removed.
- hot reloading — Having a running program pick up code changes automatically, without rebuilding or restarting by hand.
- file permissions — Rules on each file saying which user and group own it and who may read, write or run it.
- Docker socket — The file-like connection point, usually /var/run/docker.sock, through which programs send commands to the Docker daemon.
- docker run — Creates a new container from an image and starts it, in one step.
Taught in
- Bind Mounts, Permissions And Backups — Docker Architecture & Production Containers
- Environment, Secret Files And Runtime Restrictions — Docker Architecture & Production Containers
- Development Overrides, Hot Reloading And Debuggers — Docker Architecture & Production Containers
- A Producer In Python — Apache Kafka & Event Streaming
- Idempotent Consumers And Deduplication Keys — Apache Kafka & Event Streaming