arrow_back
Back

Dockerfile VOLUME: declaring mount points

Andrew Dorokhov Andrew Dorokhov schedule 1 min read

VOLUME declares a file or directory as a volume. If the path already exists in the image, its contents are copied into the volume at container start. Multiple arguments define multiple volumes.

For security and portability, you cannot bind a host directory as a volume inside a Dockerfile — use -v at runtime instead.

Example:

FROM nginx:latest
VOLUME ["/usr/share/nginx/html/"]
code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

Dockerfile USER: running processes as non-root

arrow_forward