Skip to content

Commit 7339a6d

Browse files
authored
Merge pull request #2546 from infosiftr/dind-rootless
Move rootless notes to a variant stub
2 parents b69d912 + 7195708 commit 7339a6d

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

docker/content.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Inside the directory specified by `DOCKER_TLS_CERTDIR`, the entrypoint scripts w
3232

3333
In order to make use of this functionality from a "client" container, at least the `client` subdirectory of the `$DOCKER_TLS_CERTDIR` directory needs to be shared (as illustrated in the following examples).
3434

35-
To disable this image behavior, simply override the container command or entrypoint to run `dockerd` directly (`... docker:dind dockerd ...` or `... --entrypoint dockerd docker:dind ...`).
35+
To disable this image behavior, simply override the container command or entrypoint to run `dockerd` directly (`... %%IMAGE%%:dind dockerd ...` or `... --entrypoint dockerd %%IMAGE%%:dind ...`).
3636

3737
## Start a daemon instance
3838

@@ -205,25 +205,6 @@ $ docker run --privileged --name some-docker -d \
205205

206206
Some of these will not be supported based on the settings on the host's `dockerd`, such as `--ulimit nofile=-1`, giving errors that look like `error setting rlimit type 7: operation not permitted`, and some may inherit sane values from the host `dockerd` instance or may not apply for your usage of Docker-in-Docker (for example, you likely want to set `--oom-score-adj` to a value that's higher than `dockerd` on the host so that your Docker-in-Docker instance is killed before the host Docker instance is).
207207

208-
## Rootless
209-
210-
For more information about using the experimental "rootless" image variants, see [docker-library/docker#174](https://github.com/docker-library/docker/pull/174).
211-
212-
**Note:** just like the regular `dind` images, `--privileged` is required for Docker-in-Docker to function properly ([docker-library/docker#151](https://github.com/docker-library/docker/issues/151#issuecomment-483185972) & [docker-library/docker#281](https://github.com/docker-library/docker/issues/281#issuecomment-744766015)). For `19.03.x` rootless images, an argument of `--experimental` is required for `dockerd` ([docker/docker#40759](https://github.com/docker/docker/pull/40759)).
213-
214-
Basic example usage:
215-
216-
```console
217-
$ docker run -d --name some-docker --privileged docker:dind-rootless
218-
$ docker logs --tail=3 some-docker # to verify the daemon has finished generating TLS certificates and is listening successfully
219-
time="xxx" level=info msg="Daemon has completed initialization"
220-
time="xxx" level=info msg="API listen on /run/user/1000/docker.sock"
221-
time="xxx" level=info msg="API listen on [::]:2376"
222-
$ docker exec -it some-docker docker-entrypoint.sh sh # using "docker-entrypoint.sh" which auto-sets "DOCKER_HOST" appropriately
223-
/ $ docker info --format '{{ json .SecurityOptions }}'
224-
["name=seccomp,profile=default","name=rootless"]
225-
```
226-
227208
## Where to Store Data
228209

229210
Important note: There are several ways to store data used by applications that run in Docker containers. We encourage users of the `%%REPO%%` images to familiarize themselves with the options available, including:

docker/variant-rootless.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## `%%IMAGE%%:<version>-rootless`
2+
3+
For more information about using the experimental "rootless" image variants, see [docker-library/docker#174](https://github.com/docker-library/docker/pull/174).
4+
5+
**Note:** just like the regular `dind` images, `--privileged` is required for Docker-in-Docker to function properly ([docker-library/docker#151](https://github.com/docker-library/docker/issues/151#issuecomment-483185972) & [docker-library/docker#281](https://github.com/docker-library/docker/issues/281#issuecomment-744766015)), which is a security issue that needs to be treated appropriately.
6+
7+
Basic example usage:
8+
9+
```console
10+
$ docker run -d --name some-docker --privileged %%IMAGE%%:dind-rootless
11+
$ docker logs --tail=3 some-docker # to verify the daemon has finished generating TLS certificates and is listening successfully
12+
time="xxx" level=info msg="Daemon has completed initialization"
13+
time="xxx" level=info msg="API listen on /run/user/1000/docker.sock"
14+
time="xxx" level=info msg="API listen on [::]:2376"
15+
$ docker exec -it some-docker docker-entrypoint.sh sh # using "docker-entrypoint.sh" which auto-sets "DOCKER_HOST" appropriately
16+
/ $ docker info --format '{{ json .SecurityOptions }}'
17+
["name=seccomp,profile=default","name=rootless"]
18+
```
19+
20+
To run with a different UID/GID than the one baked into the image, modify `/etc/passwd`, `/etc/group`, and filesystem permissions (especially for the `rootless` user's home directory) as appropriate; for example:
21+
22+
```dockerfile
23+
FROM %%IMAGE%%:dind-rootless
24+
USER root
25+
RUN set -eux; \
26+
sed -i -e 's/^rootless:1000:1000:/rootless:1234:5678:/' /etc/passwd; \
27+
sed -i -e 's/^rootless:1000:/:5678:/' /etc/group; \
28+
chown -R rootless ~rootless
29+
USER rootless
30+
```

0 commit comments

Comments
 (0)