Skip to content

Add --device flag to allow additional host devices in container#6134

Closed
timthelion wants to merge 1 commit intomoby:masterfrom
timthelion:devices3
Closed

Add --device flag to allow additional host devices in container#6134
timthelion wants to merge 1 commit intomoby:masterfrom
timthelion:devices3

Conversation

@timthelion
Copy link
Copy Markdown
Contributor

I know I said I was out for the weekend, but I got up early this morning, and with a bit of repasting(it's like rebasing, but for the unenlightened), I bring you:

We add a --device flag which can be used like:

$ docker run --device /dev/sda:/dev/xvda:rwm ubuntu /bin/bash

To allow the container to have read write permissions to access the host's /dev/sda via a node named /dev/xvda in the container.

Docker-DCO-1.1-Signed-off-by: Timothy [email protected] (github: https://github.com/timthelion)

Big thanks to @dineshs-altiscale !

@timthelion
Copy link
Copy Markdown
Contributor Author

Just pushed a little tweek to make sure we don't end up passing around unparsed data in strings.

@SvenDowideit
Copy link
Copy Markdown
Contributor

docs LGTM

@timthelion
Copy link
Copy Markdown
Contributor Author

@jamtur01 Oops, thanks. Fixed.

@timthelion
Copy link
Copy Markdown
Contributor Author

Ping @crosbymichael

@calfonso
Copy link
Copy Markdown
Contributor

calfonso commented Jun 9, 2014

Looks like this might need a rebase, but after a quick test using native and lxc, it worked well.

@imain
Copy link
Copy Markdown
Contributor

imain commented Jun 9, 2014

Yeah this looks good. Better than the one I did.

@ewindisch you should take a look too.

@calfonso
Copy link
Copy Markdown
Contributor

calfonso commented Jun 9, 2014

@timthelion Here is what I had to change after a rebase from origin/master if you want to take a look or add it to your patch. calfonso@3eef699

@imain
Copy link
Copy Markdown
Contributor

imain commented Jun 10, 2014

FYI @calfonso and I are now working on a patch to add devices at runtime based on top of this work.

@timthelion
Copy link
Copy Markdown
Contributor Author

@imain , @calfonso thanks, that was gracious of you. I'm sorry your time was wasted. I have re-based.

@calfonso
Copy link
Copy Markdown
Contributor

@timthelion, @imain I've rebased off the devices3 branch and placed the devadd plumbing commit on top of it on my devadd branch (force-pushed)

@timthelion
Copy link
Copy Markdown
Contributor Author

ping @crosbymichael @vieux @creack @shykes

@timthelion
Copy link
Copy Markdown
Contributor Author

I just rebased and everything is still looking OK. @calfonso I hope that rebasing didn't break things for you, given that you based some commits off my work.

@calfonso
Copy link
Copy Markdown
Contributor

@timthelion I rebased as well, still looks good.

@calfonso
Copy link
Copy Markdown
Contributor

@timthelion have you received any out-of-band updates re this PR?

@calfonso
Copy link
Copy Markdown
Contributor

needs another rebase after updating to the latest libcontainer

@timthelion
Copy link
Copy Markdown
Contributor Author

@calfonso I have not received any news but last time I discussed this with @crosbymichael he was very aware of it, so I'm hoping that is still the case. I'll rebase soon.

@timthelion
Copy link
Copy Markdown
Contributor Author

@calfonso . @crosbymichael just rebased and tests still seem to be passing.

@timthelion
Copy link
Copy Markdown
Contributor Author

Ping @calfonso just rebased.

Ping @SvenDowideit just changed the docs to warn about a security problem.

Ping @crosbymichael @vieux when will this get merged?

@unclejack
Copy link
Copy Markdown
Contributor

I'm sorry for the late review, this is very useful.

ping @crosbymichael @vieux @tiborvass

LGTM

Comment thread daemon/container.go Outdated
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.

It'd be useful to add some context to the error.

We add a --device flag which can be used like:

 docker run --device /dev/sda:/dev/xvda:rwm ubuntu /bin/bash

To allow the container to have read write permissions to access the host's /dev/sda via a node named /dev/xvda in the container.

Note: Much of this code was written by Dinesh Subhraveti [email protected] (github: dineshs-altiscale) and so he deserves a ton of credit.

Docker-DCO-1.1-Signed-off-by: Timothy <[email protected]> (github: timthelion)
@timthelion
Copy link
Copy Markdown
Contributor Author

@tiborvass Is this better?

@crosbymichael
Copy link
Copy Markdown
Contributor

Does this work for LXC also?

@timthelion
Copy link
Copy Markdown
Contributor Author

@crosbymichael I'm not sure whether to be offended of flattered by your question ;) OF COURSE it works with lxc. What do you think that giant device refactoring PR I got through just before 1.0 was about? ;) ...

Though do keep in mind that on my machine #6671 obscures this fact. Yeah, if I do docker run -i -t -device=/dev/zero:/dev/nulo ubuntu /bin/bash then /dev/nulo is there. But there's a hell-of-alot of noise too.

@timthelion
Copy link
Copy Markdown
Contributor Author

Ping @tiborvass , @crosbymichael , @vieux

@timthelion
Copy link
Copy Markdown
Contributor Author

@crosbymichael Is there any hope of me getting an ETA on this? I have a bit of a deadline coming up in a little over a month and I'd like to know if I should be waiting for this or working on a work around.

@crosbymichael
Copy link
Copy Markdown
Contributor

#assignee=crosbymichael

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.

  1. Need to get rid of the passive voice here. Recast to something like: You may sometimes need to expose devices directly to a container.
  2. Need to have single back-ticks (`) for code style in markdown. (There are multiple instances of this throughout, I'm only flagging this one.) Also, please add "The" to avoid starting a sentence with lower-case.

@fredlf
Copy link
Copy Markdown
Contributor

fredlf commented Jul 11, 2014

@vieux @crosbymichael I added a couple of notes to clean up the docs. Not sure how I would re-open this, however.

@vieux
Copy link
Copy Markdown
Contributor

vieux commented Jul 11, 2014

@fredlf @crosbymichael is carrying this PR here: #6961

He'll do the modification there.

Thanks

@drngsl
Copy link
Copy Markdown

drngsl commented Nov 26, 2015

Hi, @calfonso , I install docker in my host with docker info
root@ubuntu:/# docker info
Containers: 52
Images: 62
Server Version: 1.9.0
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 166
Dirperm1 Supported: false
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.13.0-32-generic
Operating System: Ubuntu 14.04.1 LTS
CPUs: 16
Total Memory: 47.16 GiB
Name: ubuntu
ID: LZTA:AOAG:2X7V:SPXR:FFUP:VEFO:GIAM:3NCV:ISSG:VZVE:B4SB:KAD6
Registry: https://index.docker.io/v1/
WARNING: No swap limit support

in this verson, device modifying is not supported, so what should I do, if I want to add/remove a device to the running container?

Thanks!

@thaJeztah
Copy link
Copy Markdown
Member

@drngsl this PR is for adding a device when starting a container, there's a proposal to allow this on running containers, but it's not been decided on yet; #8826

@drngsl
Copy link
Copy Markdown

drngsl commented Nov 27, 2015

@thaJeztah , so can you tell me how can i deploy docker with source code which contains device-modifying function?

@thaJeztah
Copy link
Copy Markdown
Member

@drngsl you'd have to write that, because that PR was still in a "proposal" stage, no code was written yet, afaik

@thaJeztah
Copy link
Copy Markdown
Member

@drngsl that's not something I can answer for you; if you can build that, and you are comfortable running that code, then it's up to you to decide if you want to run it. But it won't be an official docker build, and it's not "supported".

@thaJeztah
Copy link
Copy Markdown
Member

But I'd seriously discourage running it, I just looked at those branches, and the last modifications are over a year ago, so you'd be running a really old version of docker, that doesn't have security updates, and chances are that it will no longer work with Docker Hub when registry v1 support is removed.

@drngsl
Copy link
Copy Markdown

drngsl commented Nov 27, 2015

@thaJeztah , thanks !

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.