Docker: Difference between revisions
Marked this version for translation |
Correct information for setting up rootless docker |
||
| Line 247: | Line 247: | ||
<translate> | <translate> | ||
<!--T:37--> | <!--T:37--> | ||
Rootless Docker lets you run the Docker daemon as a non-root user for improved security. | [https://docs.docker.com/engine/security/rootless/ Rootless Docker] lets you run the Docker daemon as a non-root user for improved security. To do so, enable {{nixos:option|virtualisation.docker.rootless}}. This activates the user-level systemd Docker service. Additionally, the option {{nixos:option|virtualisation.docker.rootless.setSocketVariable|setSocketVariable}} configures the <code>DOCKER_HOST</code> environment variable to point to the rootless Docker instance. | ||
</translate> | </translate> | ||
< | <syntaxhighlight lang="nix"> | ||
virtualisation.docker = { | |||
# Consider disabling the system wide Docker daemon | |||
enable = false; | |||
rootless = { | |||
enable = true; | |||
setSocketVariable = true; | |||
# Optionally customize rootless Docker daemon settings | |||
daemon.settings = { | |||
dns = [ "1.1.1.1" "8.8.8.8" ]; | |||
registry-mirrors = [ "https://mirror.gcr.io" ]; | |||
}; | |||
}; | |||
}; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
<translate> | <translate> | ||
<!--T:39--> | <!--T:39--> | ||
A system reboot is required for these changes to take effect. Alternatively, the environment variable can be set manually in the current shell session, and the user Docker service can be started with the following commands: | |||
</translate> | </translate> | ||
<syntaxhighlight lang=" | |||
<syntaxhighlight lang="console"> | |||
$ export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock | |||
$ systemctl --user start docker | $ systemctl --user start docker | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 268: | Line 279: | ||
<translate> | <translate> | ||
<!--T:40--> | <!--T:40--> | ||
To verify the status of the rootless Docker service: | |||
</translate> | </translate> | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="console"> | ||
$ systemctl --user status docker | $ systemctl --user status docker | ||
</syntaxhighlight> | </syntaxhighlight> | ||
To confirm that Docker is running in rootless mode: | |||
<syntaxhighlight lang="console"> | |||
$ docker info -f "{{println .SecurityOptions}}" | grep rootless | |||
</syntaxhighlight> | |||
<translate> | <translate> | ||
=== Creating images with Nix === <!--T:41--> | === Creating images with Nix === <!--T:41--> | ||
</translate> | </translate> | ||