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

fix error when docker daemon is running with user namespace enabled. #2161

Merged
merged 1 commit into from
Jan 31, 2017

Conversation

jjqq2013
Copy link
Contributor

Hi, i have my docker daemon run with user namespace enabled(All users in containers will be mapped to sub user of specified external user),

When i start /usr/local/bin/scope, it reports

1:"Privileged mode is incompatible with user namespaces".

Then modify the script, add --userns=host to let it share user namespace with host.

2:"Cannot share the host's network namespace when user namespaces are enabled".

The same reason and solution with 1.

That's all, hope helpful.

@2opremio
Copy link
Contributor

2opremio commented Jan 27, 2017

Thanks for this!

This change assumes that the running Docker Engine version is >= 1.10 , which is "only" one year old (some distros may not have caught up).

@QianJin2013 Could you conditionally incorporate the --userns=host flag only if the docker engine version is >= 1.10 ?

@2opremio
Copy link
Contributor

@bboreham You may want to take this into consideration for Weave Net as well.

@rade
Copy link
Member

rade commented Jan 27, 2017

TBH, I reckon mandating Docker >=1.10 is fine - Weave Net will do that from the next release onwards anyway.

@2opremio
Copy link
Contributor

@rade Will you explicitly be checking the Docker version on launch or is it implicit?

@rade
Copy link
Member

rade commented Jan 27, 2017

no idea. @bboreham will know.

@jjqq2013
Copy link
Contributor Author

ok, i will add a check whether or not support --userns=host

@2opremio
Copy link
Contributor

@QianJin2013 Hold on, it may not be necessary. It seems almost all users run >= 1.10 anyways

@jjqq2013
Copy link
Contributor Author

jjqq2013 commented Jan 27, 2017

@2opremio yeah, not much necessary.

If anyone want, i will use

docker run --help |grep -q -- --userns && USERNS_HOST="--userns=host"

@jjqq2013 jjqq2013 force-pushed the master branch 2 times, most recently from 648e0fa to 359a177 Compare January 30, 2017 15:18
@alban
Copy link
Contributor

alban commented Jan 30, 2017

Since $USERNS_HOST can be empty and in that case we don't want it to be considered a parameter, I think you will need to add # shellcheck disable=SC2086 just before using it the second time so that CircleCI can run shellcheck correctly.

See also https://github.com/koalaman/shellcheck/wiki/SC2086

@jjqq2013 jjqq2013 force-pushed the master branch 2 times, most recently from 70b404e to 28d6f33 Compare January 30, 2017 15:24
@jjqq2013
Copy link
Contributor Author

@alban OK, added shellcheck disable=SC2086, rebased, conflict resolved.

@bboreham
Copy link
Collaborator

It seems that --userns=host was added in Docker 1.11, not in 1.10 - moby/moby#20111

So your current proposed mitigation is workable; the original assumption that since we mandate 1.10 we're ok is not.

@jjqq2013
Copy link
Contributor Author

anyway, for docker which does not support --userns, this patch also works without error.

@@ -22,6 +22,8 @@ IP_ADDR_CMD="find /sys/class/net -type l | xargs -n1 basename | grep -vE 'docker
xargs -n1 ip addr show | grep inet | awk '{ print \$2 }' | grep -oE '$IP_REGEXP'"
WEAVESCOPE_DOCKER_ARGS=${WEAVESCOPE_DOCKER_ARGS:-}

docker run --help |grep -q -- --userns && USERNS_HOST="--userns=host"

This comment was marked as abuse.

@2opremio
Copy link
Contributor

anyway, for docker which does not support --userns, this patch also works without error.

Fair enough.

LGTM, modulo a descriptive comment. @QianJin2013 I will merge after you add it.

@jjqq2013
Copy link
Contributor Author

ok, comment added. Seems too long, i am not good at english, sorry.

# "Cannot share the host's network namespace when user namespaces are enabled" for `docker run --net=host`
# To avoid above errors, use `--userns=host` option to let container use host User Namespace.
# This option(saved in $USERNS_HOST) will be inserted ONLY IF docker support `--userns` option.
docker run --help |grep -q -- --userns && USERNS_HOST="--userns=host"

This comment was marked as abuse.

This comment was marked as abuse.

1:"Privileged mode is incompatible with user namespaces".
2:"Cannot share the host's network namespace when user namespaces are enabled".
@jjqq2013
Copy link
Contributor Author

OK, added

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.

5 participants