Skip to content

Allow engine to run inside a user namespace#25672

Merged
crosbymichael merged 2 commits intomoby:masterfrom
estesp:run-docker-in-userns
Aug 16, 2016
Merged

Allow engine to run inside a user namespace#25672
crosbymichael merged 2 commits intomoby:masterfrom
estesp:run-docker-in-userns

Conversation

@estesp
Copy link
Contributor

@estesp estesp commented Aug 12, 2016

Carry of PR #20902

Allow the Docker daemon to run inside a user namespaced parent process. Original patch by @hallyn; I've added a change to revert to "real" chroot when inside a userns that came about since the original patch.

I have tested this capability inside lxc running an ubuntu:xenial image with a binary built from this PR patchset. To successfully run the Docker daemon I used the following command line:

dockerd -D -s vfs --oom-score-adjust=0

Inside a user namespace, writing to the oom_score_adj special proc file fails, and I can't get any backend driver to work outside of vfs.

I cannot run the Docker engine inside of a runc container with user namespaces enabled due to how the /sys/fs/cgroups mount is handled under runc. Therefore it is hard to write a test that integrates well with our CI system without requiring a working LXC setup until we solve this problem in runc.

hallyn and others added 2 commits August 12, 2016 16:26
If we are running in a user namespace, don't try to mknod as
it won't be allowed.  libcontainer will bind-mount the host's
devices over files in the container anyway, so it's not needed.

The chrootarchive package does a chroot (without mounting /proc) before
its work, so we cannot check /proc/self/uid_map when we need to.  So
compute it in advance and pass it along with the tar options.

Signed-off-by: Serge Hallyn <[email protected]>
The namespace unshare+pivot root is not possible when running inside a
user namespace, so fallback to the original "real" chroot code.

Docker-DCO-1.1-Signed-off-by: Phil Estes <[email protected]>
@justincormack
Copy link
Contributor

justincormack commented Aug 13, 2016

LGTM but I think we should document the cant-create-devices restriction somewhere (probably dont need to mention the chroot) as it is not something people would necessarily realise. Plus the --oom-score-adjust=0 and other restrictions. Not sure where, maybe in the security docs?

@kimh
Copy link

kimh commented Aug 14, 2016

@estesp Thanks for the PR.

I used lxd and launched a container with lxc launch ubuntu-daily:16.04 docker -p default -p docker and I can run docker inside the container.

@estesp
Copy link
Contributor Author

estesp commented Aug 15, 2016

@justincormack agree on the docs need..but where? Is that the same section as user namespaces support in the daemon, or some other place that talks about environment in which you run the daemon? Seems like it should be the latter, but that points to less clear locations as there are lots of various bits about running/configuring the engine.. any guidance appreciated! /cc @thaJeztah

@thaJeztah
Copy link
Member

I think we could think of moving user namespaces to a separate document, instead of cramming it all in the dockerd reference; that way we can provide a bit more context, tips/tricks and explain when it's useful (and when not).

ping @sfsmithcha wdyt?

@justincormack
Copy link
Contributor

@thaJeztah but this is about running docker inside a user namespace, really goes in the how to install/run docker section.

@thaJeztah
Copy link
Member

@justincormack oh, darn, was too quick answering. erm, yes, good question not sure where to put that; it's not a regular install, same as we don't document "docker in docker"

@justincormack
Copy link
Contributor

Yes, lets maybe leave the docs for now...

LGTM

@vdemeester
Copy link
Member

vdemeester commented Aug 16, 2016

LGTM 🐱
/cc @crosbymichael @cpuguy83

@thaJeztah thaJeztah added this to the 1.13.0 milestone Aug 16, 2016
@crosbymichael
Copy link
Contributor

LGTM

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.

8 participants