-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Closed
Closed
Copy link
Labels
kind/enhancementEnhancements are not bugs or new features but can improve usability or performance.Enhancements are not bugs or new features but can improve usability or performance.
Description
This behavior seems to have been around for a while but is unexpected. Try mounting a nonexistent host path as a volume:
docker run -v /abc:/mnt busybox
The /abc directory will be created on the host:
docker@dev:/$ ls
abc/ dev/ home/ lib/ linuxrc opt/ root/ sbin/ tmp var/
bin/ etc/ init lib64 mnt/ proc/ run/ sys/ usr/
This happens even if you attempted to mount the host path as readonly (-v /abc:/mnt:ro), which is even more unexpected. This behavior is particularly problematic when attempting to mount a file which may or may not exist — Docker creates a directory at the file path, which can cause problems down the road.
This behavior seems to be quite old (since at least 1.2.0), but doesn't seem to be documented.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind/enhancementEnhancements are not bugs or new features but can improve usability or performance.Enhancements are not bugs or new features but can improve usability or performance.