-
Notifications
You must be signed in to change notification settings - Fork 620
Add experimental "rootless" dind variant #174
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| FROM docker:19.03-rc-dind | ||
|
|
||
| # busybox "ip" is insufficient: | ||
| # [rootlesskit:child ] error: executing [[ip tuntap add name tap0 mode tap] [ip link set tap0 address 02:50:00:00:00:01]]: exit status 1 | ||
| RUN apk add --no-cache iproute2 | ||
|
|
||
| # "/run/user/UID" will be used by default as the value of XDG_RUNTIME_DIR | ||
| RUN mkdir /run/user && chmod 1777 /run/user | ||
|
|
||
| # create a default user preconfigured for running rootless dockerd | ||
| RUN set -eux; \ | ||
| adduser -h /home/rootless -g 'Rootless' -D -u 1000 rootless; \ | ||
| echo 'rootless:100000:65536' >> /etc/subuid; \ | ||
| echo 'rootless:100000:65536' >> /etc/subgid | ||
|
|
||
| RUN set -eux; \ | ||
| \ | ||
| # this "case" statement is generated via "update.sh" | ||
| apkArch="$(apk --print-arch)"; \ | ||
| case "$apkArch" in \ | ||
| # amd64 | ||
| x86_64) dockerArch='x86_64' ;; \ | ||
| # arm32v6 | ||
| armhf) dockerArch='armel' ;; \ | ||
| # arm32v7 | ||
| armv7) dockerArch='armhf' ;; \ | ||
| # arm64v8 | ||
| aarch64) dockerArch='aarch64' ;; \ | ||
| *) echo >&2 "error: unsupported architecture ($apkArch)"; exit 1 ;;\ | ||
| esac; \ | ||
| \ | ||
| if ! wget -O rootless.tgz "https://download.docker.com/linux/static/${DOCKER_CHANNEL}/${dockerArch}/docker-rootless-extras-${DOCKER_VERSION}.tgz"; then \ | ||
| echo >&2 "error: failed to download 'docker-rootless-extras-${DOCKER_VERSION}' from '${DOCKER_CHANNEL}' for '${dockerArch}'"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| \ | ||
| tar --extract \ | ||
| --file rootless.tgz \ | ||
| --strip-components 1 \ | ||
| --directory /usr/local/bin/ \ | ||
| 'docker-rootless-extras/vpnkit' \ | ||
| ; \ | ||
| rm rootless.tgz; \ | ||
| \ | ||
| # we download/build rootlesskit separately to get a newer release | ||
| # rootlesskit --version; \ | ||
| vpnkit --version | ||
|
|
||
| # https://github.com/rootless-containers/rootlesskit/releases | ||
| ENV ROOTLESSKIT_VERSION 0.6.0 | ||
|
|
||
| RUN set -eux; \ | ||
| apk add --no-cache --virtual .rootlesskit-build-deps \ | ||
| go \ | ||
tianon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| libc-dev \ | ||
| ; \ | ||
| wget -O rootlesskit.tgz "https://github.com/rootless-containers/rootlesskit/archive/v${ROOTLESSKIT_VERSION}.tar.gz"; \ | ||
| export GOPATH='/go'; mkdir "$GOPATH"; \ | ||
| mkdir -p "$GOPATH/src/github.com/rootless-containers/rootlesskit"; \ | ||
| tar --extract --file rootlesskit.tgz --directory "$GOPATH/src/github.com/rootless-containers/rootlesskit" --strip-components 1; \ | ||
| rm rootlesskit.tgz; \ | ||
| go build -o /usr/local/bin/rootlesskit github.com/rootless-containers/rootlesskit/cmd/rootlesskit; \ | ||
| go build -o /usr/local/bin/rootlesskit-docker-proxy github.com/rootless-containers/rootlesskit/cmd/rootlesskit-docker-proxy; \ | ||
| rm -rf "$GOPATH"; \ | ||
| apk del --no-network .rootlesskit-build-deps; \ | ||
| rootlesskit --version | ||
|
|
||
| # pre-create "/var/lib/docker" for our rootless user | ||
| RUN set -eux; \ | ||
| mkdir -p /home/rootless/.local/share/docker; \ | ||
| chown -R rootless:rootless /home/rootless/.local/share/docker | ||
| VOLUME /home/rootless/.local/share/docker | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer setting
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and also
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The expected usage there would be either |
||
| USER rootless | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: the origin of the binary is
djs55/vpnkitimage https://github.com/moby/moby/blob/7cfd8146dc6089a5f21415dc4c0a609a93c507fe/Dockerfile#L249There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: If you don't like the VPNKit binary footprint, https://github.com/rootless-containers/slirp4netns can be used instead of VPNKit.
slirp4netns is licensed under GPL2 and not included in the docker-rootless-extras.tgz because they didn't want to include GPL2 binary in the same tgz, but probably it doesn't hurt to put slirp4netns in Docker images.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind the footprint (or
vpnkitin general -- I understand it's been used in Docker Desktop for a pretty respectable amount of time now, so it's "tested, tried, and true" so to speak) -- the issue I've got is with the need to pull this extra bundle which we then have to wait for a new Docker release to get an update to if there happens to be some issue that's resolved in a newer release ofvpnkit, so it'd be really neat to get some official binary releases there, but I think that's a pretty minor issue at this point (vpnkitis pretty provably solid, as noted).