Skip to content

Commit 5c6bdd6

Browse files
committed
add rootless docker page
1 parent d097d6b commit 5c6bdd6

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

docs/explanations/rootless.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Rootless vs Rootfull
2+
3+
epics-containers is intended to support both docker and podman. Docker is rootfull by default but also supports rootless operation. Podman is rootless by default but also supports rootfull operation.
4+
5+
Advantages of rootless operation include:
6+
7+
- Security: rootless containers only have the same permissions as the user running them.
8+
- Ease of use: in an environment where users do not have root privileges, rootless containers can be run without needing to escalate privileges. This is why DLS uses rootless containers.
9+
- Host mounts: host mounts have the same permissions as the user running the container.
10+
- Developer containers: rootless containers can be 'root' inside the container, but not on the host.
11+
- Simplicity: no need to switch users in Dockerfiles - just stay as root and use psuedo-root during runtime. This maps nicely to using the same container in Kubernetes where control of the user id is up to the cluster.
12+
13+
Advantages of rootfull operation include:
14+
15+
- networking: you can create rootable bridge networks that can be accessed from the host
16+
- power: you can give containers privileged capabilities that the user would not normally have
17+
18+
The advantages of rootless are ideal for developing and executing IOCs.
19+
20+
## Current situation
21+
22+
At present epics-containers requires slightly different configuration for docker and podman. However these differences are really because of the rootfull vs rootless distinction. Those distinctions for docker (rootful) are:
23+
24+
- EC_REMOTE_USER: must be set so that developer containers run as the current user
25+
- Permissions on the files inside the developer container need to be set with *sudo chown* at startup
26+
- Developer containers will sometimes have issues with git repo permissions
27+
- docker compose deployed IOCs do run as root and write any generated files as root in host mounted folders (this needs fixing)
28+
29+
## Proposed solution
30+
31+
We should mantate the use of rootless for epics-containers. This will make the configuration simpler and more secure.
32+
33+
A potential issue with this is that developers who use docker for other purposes may need to use rootfull as well.
34+
35+
This would therefore be accetable if it is easy to switch between rootfull and rootless operation. The next section shows how I have done this with docker on Ubuntu 24.04, I would guess that this will work on other distros but this needs to be verified.
36+
37+
## Configure Docker with rootless/rootfull operation
38+
39+
These instructions worked for me on Ubuntu 24.04. Assume docker default install is already done and is at version 27.2.0.
40+
41+
1. docker install comes with a script to set up rootless operation. We use --force to tell it to run even though rootfull is already set up.
42+
43+
```bash
44+
sudo dockerd-rootless-setuptool.sh --force
45+
```
46+
47+
1. The script may get errors and explain how to get around them. In my case it asked me to run this:
48+
```bash
49+
sudo sh -eux <<EOF
50+
# Install newuidmap & newgidmap binaries
51+
apt-get install -y uidmap
52+
EOF
53+
```
54+
55+
1. Make sure the rootfull service is still running (may not need this step).
56+
57+
```bash
58+
sudo systemctl enable --now docker.service docker.socket
59+
```
60+
61+
1. Now you can switch between both by changing the environment variable DOCKER_HOST.
62+
63+
1. To switch to rootless:
64+
65+
```bash
66+
export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock
67+
docker ps -a
68+
```
69+
70+
1. To switch back to rootfull:
71+
72+
```bash
73+
export DOCKER_HOST=unix:///var/run/docker.sock
74+
docker ps -a
75+
```
76+
77+
78+

0 commit comments

Comments
 (0)