Skip to content

add dockerd-rootless-setuptool.sh#40950

Merged
cpuguy83 merged 1 commit into
moby:masterfrom
AkihiroSuda:dockerd-rootless-setuptool.sh
May 21, 2020
Merged

add dockerd-rootless-setuptool.sh#40950
cpuguy83 merged 1 commit into
moby:masterfrom
AkihiroSuda:dockerd-rootless-setuptool.sh

Conversation

@AkihiroSuda

Copy link
Copy Markdown
Member

- What I did

Added contrib/dockerd-rootless-setuptool.sh.

The tool is expected to be used by https://get.docker.com/rootless script.

Can be included in RPM/DPKG packages as well.

Fix #40707
Relates to #40761
Replaces #40924 (Same as this PR but written in Go rather than in shell)

- How I did it
Rewrote https://get.docker.com/rootless .
The curl stuff is expected to be kept in https://get.docker.com/rootless .

Also, the storage driver is not detected in the new tool because the daemon should be able to choose overlay2/fuse-overlayfs/vfs automatically.

- How to verify it

Show usage:

$ dockerd-rootless-setuptool.sh --help
Usage: dockerd-rootless-setuptool.sh [OPTIONS] COMMAND

A setup tool for Rootless Docker (dockerd-rootless.sh).

Documentation: https://docs.docker.com/engine/security/rootless/

Options:
  -f, --force                Ignore rootful Docker (/var/run/docker.sock)
      --skip-iptables        Ignore missing iptables

Commands:
  check        Check prerequisites
  install      Install systemd unit (if systemd is available) and show how to manage the service
  uninstall    Uninstall systemd unit

Install (-> fail due to existing rootful Docker)

$ dockerd-rootless-setuptool.sh install
[ERROR] Aborting because rootful Docker (/var/run/docker.sock) is running and accessible. Set --force to ignore.

Install (ignore rootful Docker -> fail due to misconfiguration of subuid and subgid)

$ dockerd-rootless-setuptool.sh install --force
[ERROR] Missing system requirements. Run the following commands to
[ERROR] install the requirements and run this tool again.

########## BEGIN ##########
cat <<EOF | sudo sh -x
# Add subuid entry for suda
echo "suda:100000:65536" >> /etc/subuid
# Add subgid entry for suda
echo "suda:100000:65536" >> /etc/subgid
EOF
########## END ##########

Install (try again after fixing up subuid and subgid -> success)

$ cat <<EOF | sudo sh -x
> # Add subuid entry for suda
> echo "suda:100000:65536" >> /etc/subuid
> # Add subgid entry for suda
> echo "suda:100000:65536" >> /etc/subgid
> EOF
+ echo suda:100000:65536
+ echo suda:100000:65536
$ dockerd-rootless-setuptool.sh install --force
[INFO] Creating /home/suda/.config/systemd/user/docker.service
[INFO] starting systemd service docker.service
+ systemctl --user start docker.service
+ sleep 3
+ set +x
+ systemctl --user --no-pager --full status docker.service
● docker.service - Docker Application Container Engine (Rootless)
     Loaded: loaded (/home/suda/.config/systemd/user/docker.service; disabled; vendor preset: enabled)
     Active: active (running) since Mon 2020-05-11 23:37:26 JST; 3s ago
       Docs: https://docs.docker.com/engine/security/rootless/
   Main PID: 15810 (rootlesskit)
      Tasks: 38
     Memory: 27.3M
        CPU: 397ms
     CGroup: /user.slice/user-1001.slice/[email protected]/docker.service
             ├─15810 rootlesskit --net=slirp4netns --mtu=65520 --slirp4netns-sandbox=auto --slirp4netns-seccomp=auto --disable-host-loopback --port-driver=builtin --copy-up=/etc --copy-up=/run --propagation=rslave /usr/local/bin/dockerd-rootless.sh
             ├─15836 /proc/self/exe --net=slirp4netns --mtu=65520 --slirp4netns-sandbox=auto --slirp4netns-seccomp=auto --disable-host-loopback --port-driver=builtin --copy-up=/etc --copy-up=/run --propagation=rslave /usr/local/bin/dockerd-rootless.sh
             ├─15852 slirp4netns --mtu 65520 -r 3 --disable-host-loopback --enable-sandbox --enable-seccomp 15836 tap0
             ├─15860 dockerd
             └─15877 containerd --config /run/user/1001/docker/containerd/containerd.toml --log-level info
...
+ DOCKER_HOST=unix:///run/user/1001/docker.sock /usr/local/bin/docker version
Client:
 Version:           20.03.0-dev
 API version:       1.41
 Go version:        go1.13.10
 Git commit:        f7185d27e
 Built:             Fri May  8 05:21:12 2020
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          dev
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.10
  Git commit:       cdf49f37ee
  Built:            Fri May  8 05:18:12 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.3.0-551-g990076b7
  GitCommit:        990076b731ec9446437972b41176a6b0f3b7bcbf
 runc:
  Version:          1.0.0-rc10+dev
  GitCommit:        2b31437caa905b7b944a891aee613e7dd0a1f898
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
+ systemctl --user enable docker.service
Created symlink /home/suda/.config/systemd/user/default.target.wants/docker.service → /home/suda/.config/systemd/user/docker.service.
+ set +x
[INFO] Installed docker.service successfully.
[INFO] To control docker.service, run: `systemctl --user (start|stop|restart) docker.service`
[INFO] To run docker.service on system startup, run: `sudo loginctl enable-linger suda`

[INFO] Make sure the following environment variables are set (or add them to ~/.bashrc):

export PATH=/usr/local/bin:$PATH
export DOCKER_HOST=unix:///run/user/1001/docker.sock

Uninstall:

$ dockerd-rootless-setuptool.sh uninstall --force
+ systemctl --user stop docker.service
+ systemctl --user disable docker.service
Removed /home/suda/.config/systemd/user/default.target.wants/docker.service.
+ rm -f /home/suda/.config/systemd/user/docker.service
+ set +x -e
[INFO] Uninstalled docker.service
[INFO] This uninstallation tool does NOT remove Docker binaries and data.
[INFO] To remove data, run: `/usr/local/bin/rootlesskit rm -rf /home/suda/.local/share/docker`

- Description for the changelog

add dockerd-rootless-setuptool.sh

- A picture of a cute animal (not mandatory but encouraged)

🐧

@AkihiroSuda
AkihiroSuda requested a review from tianon as a code owner May 11, 2020 14:42
@AkihiroSuda AkihiroSuda added this to the 20.03.0 milestone May 11, 2020
@AkihiroSuda
AkihiroSuda force-pushed the dockerd-rootless-setuptool.sh branch 2 times, most recently from b6cb760 to ec4f5bc Compare May 11, 2020 14:49
@AkihiroSuda AkihiroSuda added the kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. label May 11, 2020
@AkihiroSuda
AkihiroSuda force-pushed the dockerd-rootless-setuptool.sh branch from ec4f5bc to 0d2b0b5 Compare May 11, 2020 15:01
@thaJeztah

Copy link
Copy Markdown
Member

@tianon ptal 🤗

@tianon tianon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall not bad -- I noticed a few minor typos, but most of my suggestions are stylistic/reliability changes.

I realize this is kind of a lot of suggestions so if you'd rather have a PR against your branch to review, I'm happy to do that instead. 👍

Comment thread contrib/dockerd-rootless-setuptool.sh Outdated
Comment thread contrib/dockerd-rootless-setuptool.sh Outdated
Comment thread contrib/dockerd-rootless-setuptool.sh Outdated
Comment thread contrib/dockerd-rootless-setuptool.sh Outdated
Comment thread contrib/dockerd-rootless-setuptool.sh Outdated
Comment thread contrib/dockerd-rootless-setuptool.sh Outdated
Comment thread contrib/dockerd-rootless-setuptool.sh Outdated
Comment thread contrib/dockerd-rootless-setuptool.sh Outdated
Comment thread contrib/dockerd-rootless-setuptool.sh Outdated
Comment thread contrib/dockerd-rootless-setuptool.sh Outdated
@AkihiroSuda
AkihiroSuda force-pushed the dockerd-rootless-setuptool.sh branch 2 times, most recently from e1c5bba to 527968f Compare May 14, 2020 23:30
@AkihiroSuda

Copy link
Copy Markdown
Member Author

Thanks @tianon, addressed your comments

Usage: `dockerd-rootless-setuptool.sh install --force` .
See `--help` for further information.

Co-authored-by: Tianon Gravi <[email protected]>
Signed-off-by: Akihiro Suda <[email protected]>
@AkihiroSuda
AkihiroSuda force-pushed the dockerd-rootless-setuptool.sh branch from 527968f to c696b95 Compare May 14, 2020 23:46

@tianon tianon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry noticed one more minor thing, but otherwise LGTM 👍 🎉

Comment thread contrib/dockerd-rootless-setuptool.sh
@AkihiroSuda

Copy link
Copy Markdown
Member Author

@cpuguy83
cpuguy83 merged commit 07e6b84 into moby:master May 21, 2020
AkihiroSuda added a commit to AkihiroSuda/docker-ce-packaging that referenced this pull request May 21, 2020
dockerd-rootless-setuptool.sh was added to Moby in moby/moby#40950

Signed-off-by: Akihiro Suda <[email protected]>
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this pull request May 27, 2020
dockerd-rootless-setuptool.sh was added to Moby in moby/moby#40950

Signed-off-by: Akihiro Suda <[email protected]>
Upstream-commit: 896c278
Component: packaging
HeroCC pushed a commit to HeroCC/docker-ce-packaging that referenced this pull request Oct 6, 2021
dockerd-rootless-setuptool.sh was added to Moby in moby/moby#40950

Signed-off-by: Akihiro Suda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/rootless Rootless Mode impact/changelog kind/enhancement Enhancements are not bugs or new features but can improve usability or performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move docker-install/rootless-install.sh (except the curl part) to this repo + rewrite in Go

5 participants