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.py
docker run --rm -v "$PWD:/app" m02l01-client python producer.py

Related terms

Taught in

References