How to Configure Docker in Rootless Mode?
Question
How to configure Docker in rootless mode?
Environment
Container platform: Docker
Answer
For better security, we recommend that you always run Docker in rootless mode. For more information about how to configure Docker in rootless mode, see Docker documentation.
- Using the
xfs
filesystem for/home
($HOME) is highly recommended. - A minimum of 50GB of free disk space for
/home
is recommended. - Before you enable Docker in rootless mode, make sure you stop the system-wide Docker service with the following command:
sudo systemctl disable --now docker.service docker.service
- The Docker rootless binaries will be available in the
$HOME/bin
folder. - Amazon Linux 2 does not support Docker in rootless mode. If you want to use Amazon Linux as your operating system, we recommend using the latest Amazon Linux 2023 (AL2023) x86_64 AMI.
Example steps using the docker supplied installation script (as the non-root user):
curl -fsSL "https://get.docker.com/rootless" | sh
The above commands should already have started the Docker service. If it has not started, do the following to enable and start it:
Run the following as the non-root user:
systemctl --user enable --now docker.service systemctl --user start --now docker.service systemctl --user status docker.service
Run the following command to allow services to run even after the user logs out:
sudo loginctl enable-linger <username>