Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Un-deprecate auto-creation of host directories for mounts #21666

Merged
merged 1 commit into from Mar 30, 2016

Conversation

thaJeztah
Copy link
Member

Auto-creation of host-directories was marked deprecated in
Docker 1.9, but was decided to be too much of an backward-incompatible
change, so it was decided to keep the feature.

fixes #21652, refs #19953 (comment))

Auto-creation of host-directories was marked deprecated in
Docker 1.9, but was decided to be too much of an backward-incompatible
change, so it was decided to keep the feature.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@cpuguy83
Copy link
Member

LGTM

@calavera
Copy link
Contributor

🎉 LGTM

@calavera calavera merged commit 9d5c26b into moby:master Mar 30, 2016
@thaJeztah thaJeztah deleted the undeprecate-auto-generated-paths branch March 30, 2016 22:21
@glensc
Copy link
Contributor

glensc commented May 24, 2018

Can this be addressed with some new mount option?

docker run --rm -it -v ~/.my.cnf:/root/.my.cnf:no-create busybox

@thaJeztah
Copy link
Member Author

@glensc you can now use the --mount flag instead;

docker run --mount type=bind,source=~/.my.cnf,target=/root/.my.cnf busybox

The --mount type=bind..... flag will produce an error if the source file/directory does not exist

@glensc
Copy link
Contributor

glensc commented May 24, 2018

@thaJeztah awesomeness!

this is certainly good, because paths that are expected to be files became dirs create weird application failures :)

is there a solution for soft fail too? i.e don't create bind if source missing? as I want to add such bind to docker compose and not all users (who use the compose) may have the file present.

@thaJeztah
Copy link
Member Author

is there a solution for soft fail too? i.e don't create bind if source missing? as I want to add such bind to docker compose and not all users (who use the compose) may have the file present.

Not directly; in general I would recommend bind-mounting directories instead of files. Mounting files can have odd behavior

For example, binds in Linux are based on the file/directory's inode, not their path. Some editors do not edit a file in place, but instead: save to a temporary file, then move the original file, and write the updated file to the old location. In that situation, the container would still be using the old file (before editing), which can be unexpected.

So, instead of bind-mounting ~/.my.cnf, bind-mount (for example) ~/configuration-files/ (and for that case you could use the old "auto-create" feature); if the user doesn't have that directory, docker creates an empty directory, but if it exists, it will be mounted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation unclear on auto creating missing host paths for bind mounts deprecation
5 participants