Skip to content

deprecate bind path auto-create#16349

Merged
calavera merged 1 commit intomoby:masterfrom
cpuguy83:16302_deprecate_autocreate_binds
Sep 18, 2015
Merged

deprecate bind path auto-create#16349
calavera merged 1 commit intomoby:masterfrom
cpuguy83:16302_deprecate_autocreate_binds

Conversation

@cpuguy83
Copy link
Copy Markdown
Member

Fixes #16302
Fixes #12776
Fixes #13468
I'm sure a few more that I could not find again.

ping @calavera

@calavera
Copy link
Copy Markdown
Contributor

@cpuguy83 I think we should show a warning in the client when this happens.

@docker/maintainers Please, take a look. This is source of much confusion among users and we'd like to deprecate it.

@tiborvass
Copy link
Copy Markdown
Contributor

warning is fine for me

@tianon
Copy link
Copy Markdown
Member

tianon commented Sep 16, 2015

Definitely +1 for deprecation, and +1 for a warning 👍 🤘

@duglin
Copy link
Copy Markdown
Contributor

duglin commented Sep 16, 2015

sgtm

@calavera
Copy link
Copy Markdown
Contributor

Just to clarify, I meant to show a warning saying that we auto-created the directory but it's a deprecated feature and we're going to stop doing it.

@abronan
Copy link
Copy Markdown
Contributor

abronan commented Sep 16, 2015

Agreed for deprecating/removing it, SGTM

@thaJeztah
Copy link
Copy Markdown
Member

+1 for removing this "feature", and +1 for outputting a warning now (including a "deprecation" message?)

(If we want a "warning" in 1.9, please add that change to this PR)

The documentation changes in this PR can use a slight touch-up, but I'll wait until it's been agreed on.

@cpuguy83
Copy link
Copy Markdown
Member Author

Presenting the user with a warning is not a small change.
Warning the daemon logs is simple enough.

Not sure about presenting a warning to the user here unless we just do it for all binds.

@cpuguy83
Copy link
Copy Markdown
Member Author

And then it would just be on the client.

@moxiegirl
Copy link
Copy Markdown
Contributor

LGTM @thaJeztah touch up at will it looks ok by me. Didn't we just have a pr touching on bind mount --- #13776? Does that language still work in light of this...bit late for me...maybe I'm not clear

@stevvooe
Copy link
Copy Markdown
Contributor

👍

@calavera
Copy link
Copy Markdown
Contributor

@cpuguy83 maybe the daemon log is good enough, that's what we did with LXC:

https://github.com/docker/docker/pull/15255/files

Can you add it here?

@cpuguy83 cpuguy83 force-pushed the 16302_deprecate_autocreate_binds branch from b66102b to 39d4b12 Compare September 17, 2015 15:41
@cpuguy83
Copy link
Copy Markdown
Member Author

Pushed with daemon log added.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to check for an error that is not a os.IsNotExist and handle that appropriately:

if fi, err := os.Stat(m.Source); err != nil {
 if !os.IsNotExist(err) {
     //.. handle error 
 }
 logrus.Warnf("Auto-creating non-existant volume host path %s, this is deprecated and will be removed soon", m.Source)
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we can, though this would picked up by the subsequent os.MkdirAll anyway.
But since we're already adding the stat call, might as well handle earlier.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hah, the worst part is we were already doing this, and this is already wrapped in a stat call... silly me.

@cpuguy83 cpuguy83 force-pushed the 16302_deprecate_autocreate_binds branch from 39d4b12 to 249f45b Compare September 18, 2015 14:28
@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented Sep 18, 2015

LGTM

@calavera
Copy link
Copy Markdown
Contributor

LGTM. Merging since #16287 takes care of the deprecation note in the run page mentioned by @moxiegirl .

calavera added a commit that referenced this pull request Sep 18, 2015
@calavera calavera merged commit e61abac into moby:master Sep 18, 2015
@m59peacemaker
Copy link
Copy Markdown

m59peacemaker commented Jul 10, 2016

The way I'm understanding this, if /foo doesn't exist on the host and I do:

docker run -v /foo:/foo etc

/foo shouldn't be created on the host. I'm on 1.11 and the directory is still created.

There isn't even a warning. Am I misreading this?

@thaJeztah
Copy link
Copy Markdown
Member

@m59peacemaker this change was later reverted; see #19953 (comment), and #21666

@m59peacemaker
Copy link
Copy Markdown

m59peacemaker commented Jul 10, 2016

@thaJeztah Well, that's unfortunate.. I commented my issue here: #19953 (comment)

Thanks for letting me know.

@stevvooe
Copy link
Copy Markdown
Contributor

@thaJeztah Auto-creation of bind paths is why we can't have nice things. This model is extremely broken.

Any way we can re-deprecate this?

@thaJeztah
Copy link
Copy Markdown
Member

@stevvooe I know 😞. To re-deprecate, I think best start would be to open an issue or PR for discussion

@tiborvass
Copy link
Copy Markdown
Contributor

We can't deprecate this, there are scripts relying on this misfeature.

@cpuguy83
Copy link
Copy Markdown
Member Author

I wish we got the new mounts (for containers) API in for 1.12 so that at least services didn't have to propagate this nastiness.

@m59peacemaker
Copy link
Copy Markdown

@tiborvass The nocreate option you mentioned here is all I need. You said it wouldn't be useful, but I think my situation calls for it. See #19953 (comment)

@diego-treitos
Copy link
Copy Markdown

In my opinion the directory auto-creation and mounting a host file as a data volume are incompatible options.
If you can truly mount any type of file (directory, normal file, socket, pipe, etc) then you cannot auto-create in case it does not exist because you dont know what to create and even if you knew you cannot control the permissions it will have on creation so it might create problems too. This feature makes no sense.

If you truly want to have a feature like this you would need options like:

  • create-d: Auto-create directory if missing. Default option for backwards compatibility.
  • create-p: Auto-create pipe if missing
  • create-s: Auto-create socket if missing
  • create-f: Auto-create regular file if missing
  • create-none: Disable auto-creation

and also have an option for <user_id>:<group_id>:<permissions> of the file being autocreated. So you could end up with something like:

$ docker run --rm -it -v '/var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock:rw:create-s:mysql:mysql:777' ubuntu /bin/bash

This way you have full control over the result of starting a container.

For now, just being able to disable autocreation with nocreate would help to fix many systems although I dont think it is a full solution in the long term in case you want a fully functional auto-create feature.

@thaJeztah
Copy link
Copy Markdown
Member

Plans are to provide an "advanced" syntax for docker run, similar to the --mount flag on docker service create. When using the advanced syntax, auto-creation will be disabled for bind-mounts, and the user will be responsible for creating the mounted directory, file (or socket) before the container is started. The intent of bind-mounting something from the host is to allow a container access to something that exists on the host, not to have docker create something on the host (i.e. docker manages anything inside /var/lib/docker, but outside of that, it should not be managing things).

The current "shorthand" syntax for bind-mounts -v /foo/bar:/container/path will likely not be modified (for reasons of backward compatibility).

@diego-treitos
Copy link
Copy Markdown

@thaJeztah thanks a lot for the update. That sounds really good and makes a lot of sense. Looking forward to see those changes :)

@fwanggg
Copy link
Copy Markdown

fwanggg commented Sep 28, 2017

wise decision to leave existing syntax's behavior unchanged. some monitoring solutions leverages the auto-create feature to install their software.

@thaJeztah
Copy link
Copy Markdown
Member

To update my earlier comment: the --mount syntax was implemented in #32251, and is included in docker 17.05 and up

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.