Using Docker with sudo
🔒 Security & Troubleshooting
·
Updated 5 days ago
Using Docker with sudo
If Docker only runs with elevated privileges on a server, /diag detects it automatically: it tries docker, sudo -n docker and common paths in turn and stores the working variant as docker_cmd.
The prerequisite for sudo -n docker is a passwordless sudoers entry:
<user> ALL=(ALL) NOPASSWD: /usr/bin/docker
The -n ensures sudo never asks for a password (otherwise the command would hang). Before use, the docker_cmd is validated against an allowlist.