Run the Docker daemon as a non-root user (Rootless mode) (2024)

Rootless mode allows running the Docker daemon and containers as a non-rootuser to mitigate potential vulnerabilities in the daemon andthe container runtime.

Rootless mode does not require root privileges even during the installation ofthe Docker daemon, as long as theprerequisites are met.

Rootless mode executes the Docker daemon and containers inside a user namespace.This is very similar touserns-remap mode, except thatwith userns-remap mode, the daemon itself is running with root privileges,whereas in rootless mode, both the daemon and the container are running withoutroot privileges.

Rootless mode does not use binaries with SETUID bits or file capabilities,except newuidmap and newgidmap, which are needed to allow multipleUIDs/GIDs to be used in the user namespace.

Prerequisites

  • You must install newuidmap and newgidmap on the host. These commandsare provided by the uidmap package on most distros.

  • /etc/subuid and /etc/subgid should contain at least 65,536 subordinateUIDs/GIDs for the user. In the following example, the user testuser has65,536 subordinate UIDs/GIDs (231072-296607).

$ id -u1001$ whoamitestuser$ grep ^$(whoami): /etc/subuidtestuser:231072:65536$ grep ^$(whoami): /etc/subgidtestuser:231072:65536

Distribution-specific hint

Tip

We recommend that you use the Ubuntu kernel.

  • Install dbus-user-session package if not installed. Run sudo apt-get install -y dbus-user-session and relogin.

  • overlay2 storage driver is enabled by default(Ubuntu-specific kernel patch).

  • Ubuntu 24.04 and later enables restricted unprivileged user namespaces bydefault, which prevents unprivileged processes in creating user namespacesunless an AppArmor profile is configured to allow programs to useunprivileged user namespaces.

    If you install docker-ce-rootless-extras using the deb package (apt-get install docker-ce-rootless-extras), then the AppArmor profile forrootlesskit is already bundled with the apparmor deb package. With thisinstallation method, you don't need to add any manual the AppArmorconfiguration. If you install the rootless extras using theinstallationscript, however, you must add an AppArmorprofile for rootlesskit manually:

    1. Add the AppArmor profile to /etc/apparmor.d/usr.local.bin.rootlesskit:

      $ cat <<EOF > /etc/apparmor.d/$(echo $HOME/bin/rootlesskit | sed -e s@^/@@ -e s@/@.@g)abi <abi/4.0>,include <tunables/global>$HOME/bin/rootlesskit flags=(unconfined) { userns, include if exists <local/$(echo $HOME/bin/rootlesskit | sed -e s@^/@@ -e s@/@.@g)>}EOF
    2. Restart AppArmor.

      $ systemctl restart apparmor.service
  • Install dbus-user-session package if not installed. Run sudo apt-get install -y dbus-user-session and relogin.

  • For Debian 10, add kernel.unprivileged_userns_clone=1 to /etc/sysctl.conf (or/etc/sysctl.d) and run sudo sysctl --system. This step is not required on Debian 11.

  • Installing fuse-overlayfs is recommended. Run sudo apt-get install -y fuse-overlayfs.Using overlay2 storage driver with Debian-specific modprobe option sudo modprobe overlay permit_mounts_in_userns=1 is also possible,however, highly discouraged due toinstability.

  • Rootless docker requires version of slirp4netns greater than v0.4.0 (when vpnkit is not installed).Check you have this with

    $ slirp4netns --version

    If you do not have this download and install with sudo apt-get install -y slirp4netns or download the latestrelease.

  • Installing fuse-overlayfs is recommended. Run sudo pacman -S fuse-overlayfs.

  • Add kernel.unprivileged_userns_clone=1 to /etc/sysctl.conf (or/etc/sysctl.d) and run sudo sysctl --system

  • Installing fuse-overlayfs is recommended. Run sudo zypper install -y fuse-overlayfs.

  • sudo modprobe ip_tables iptable_mangle iptable_nat iptable_filter is required.This might be required on other distros as well depending on the configuration.

  • Known to work on openSUSE 15 and SLES 15.

  • Installing fuse-overlayfs is recommended. Run sudo dnf install -y fuse-overlayfs.

  • You might need sudo dnf install -y iptables.

  • Known to work on CentOS 8, RHEL 8, and Fedora 34.

  • Add user.max_user_namespaces=28633 to /etc/sysctl.conf (or/etc/sysctl.d) and run sudo sysctl --system.

  • systemctl --user does not work by default.Run dockerd-rootless.sh directly without systemd.

  • Only the following storage drivers are supported:
    • overlay2 (only if running with kernel 5.11 or later, or Ubuntu-flavored kernel)
    • fuse-overlayfs (only if running with kernel 4.18 or later, and fuse-overlayfs is installed)
    • btrfs (only if running with kernel 4.18 or later, or ~/.local/share/docker is mounted with user_subvol_rm_allowed mount option)
    • vfs
  • Cgroup is supported only when running with cgroup v2 and systemd. SeeLimiting resources.
  • Following features are not supported:
    • AppArmor
    • Checkpoint
    • Overlay network
    • Exposing SCTP ports
  • To use the ping command, seeRouting ping packets.
  • To expose privileged TCP/UDP ports (< 1024), seeExposing privileged ports.
  • IPAddress shown in docker inspect is namespaced inside RootlessKit's network namespace.This means the IP address is not reachable from the host without nsenter-ing into the network namespace.
  • Host network (docker run --net=host) is also namespaced inside RootlessKit.
  • NFS mounts as the docker "data-root" is not supported. This limitation is not specific to rootless mode.

Install

Note

If the system-wide Docker daemon is already running, consider disabling it:

$ sudo systemctl disable --now docker.service docker.socket

If you installed Docker 20.10 or later withRPM/DEB packages, you should have dockerd-rootless-setuptool.sh in /usr/bin.

Run dockerd-rootless-setuptool.sh install as a non-root user to set up the daemon:

$ dockerd-rootless-setuptool.sh install[INFO] Creating /home/testuser/.config/systemd/user/docker.service...[INFO] Installed docker.service successfully.[INFO] To control docker.service, run: `systemctl --user (start|stop|restart) docker.service`[INFO] To run docker.service on system startup, run: `sudo loginctl enable-linger testuser`[INFO] Make sure the following environment variables are set (or add them to ~/.bashrc):export PATH=/usr/bin:$PATHexport DOCKER_HOST=unix:///run/user/1000/docker.sock

If dockerd-rootless-setuptool.sh is not present, you may need to install the docker-ce-rootless-extras package manually, e.g.,

$ sudo apt-get install -y docker-ce-rootless-extras

If you do not have permission to run package managers like apt-get and dnf,consider using the installation script available athttps://get.docker.com/rootless.Since static packages are not available for s390x, hence it is not supported for s390x.

$ curl -fsSL https://get.docker.com/rootless | sh...[INFO] Creating /home/testuser/.config/systemd/user/docker.service...[INFO] Installed docker.service successfully.[INFO] To control docker.service, run: `systemctl --user (start|stop|restart) docker.service`[INFO] To run docker.service on system startup, run: `sudo loginctl enable-linger testuser`[INFO] Make sure the following environment variables are set (or add them to ~/.bashrc):export PATH=/home/testuser/bin:$PATHexport DOCKER_HOST=unix:///run/user/1000/docker.sock

The binaries will be installed at ~/bin.

SeeTroubleshooting if you faced an error.

To remove the systemd service of the Docker daemon, run dockerd-rootless-setuptool.sh uninstall:

$ dockerd-rootless-setuptool.sh uninstall+ systemctl --user stop docker.service+ systemctl --user disable docker.serviceRemoved /home/testuser/.config/systemd/user/default.target.wants/docker.service.[INFO] Uninstalled docker.service[INFO] This uninstallation tool does NOT remove Docker binaries and data.[INFO] To remove data, run: `/usr/bin/rootlesskit rm -rf /home/testuser/.local/share/docker`

Unset environment variables PATH and DOCKER_HOST if you have added them to ~/.bashrc.

To remove the data directory, run rootlesskit rm -rf ~/.local/share/docker.

To remove the binaries, remove docker-ce-rootless-extras package if you installed Docker with package managers.If you installed Docker withhttps://get.docker.com/rootless (Install without packages),remove the binary files under ~/bin:

$ cd ~/bin$ rm -f containerd containerd-shim containerd-shim-runc-v2 ctr docker docker-init docker-proxy dockerd dockerd-rootless-setuptool.sh dockerd-rootless.sh rootlesskit rootlesskit-docker-proxy runc vpnkit

Usage

Daemon

The systemd unit file is installed as ~/.config/systemd/user/docker.service.

Use systemctl --user to manage the lifecycle of the daemon:

$ systemctl --user start docker

To launch the daemon on system startup, enable the systemd service and lingering:

$ systemctl --user enable docker$ sudo loginctl enable-linger $(whoami)

Starting Rootless Docker as a systemd-wide service (/etc/systemd/system/docker.service)is not supported, even with the User= directive.

To run the daemon directly without systemd, you need to run dockerd-rootless.sh instead of dockerd.

The following environment variables must be set:

  • $HOME: the home directory
  • $XDG_RUNTIME_DIR: an ephemeral directory that is only accessible by the expected user, e,g, ~/.docker/run.The directory should be removed on every host shutdown.The directory can be on tmpfs, however, should not be under /tmp.Locating this directory under /tmp might be vulnerable to TOCTOU attack.

Remarks about directory paths:

  • The socket path is set to $XDG_RUNTIME_DIR/docker.sock by default.$XDG_RUNTIME_DIR is typically set to /run/user/$UID.
  • The data dir is set to ~/.local/share/docker by default.The data dir should not be on NFS.
  • The daemon config dir is set to ~/.config/docker by default.This directory is different from ~/.docker that is used by the client.

Client

You need to specify either the socket path or the CLI context explicitly.

To specify the socket path using $DOCKER_HOST:

$ export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock$ docker run -d -p 8080:80 nginx

To specify the CLI context using docker context:

$ docker context use rootlessrootlessCurrent context is now "rootless"$ docker run -d -p 8080:80 nginx

Rootless Docker in Docker

To run Rootless Docker inside "rootful" Docker, use the docker:<version>-dind-rootlessimage instead of docker:<version>-dind.

$ docker run -d --name dind-rootless --privileged docker:25.0-dind-rootless

The docker:<version>-dind-rootless image runs as a non-root user (UID 1000).However, --privileged is required for disabling seccomp, AppArmor, and mountmasks.

Expose Docker API socket through TCP

To expose the Docker API socket through TCP, you need to launch dockerd-rootless.shwith DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS="-p 0.0.0.0:2376:2376/tcp".

$ DOCKERD_ROOTLESS_ROOTLESSKIT_FLAGS="-p 0.0.0.0:2376:2376/tcp" \ dockerd-rootless.sh \ -H tcp://0.0.0.0:2376 \ --tlsverify --tlscacert=ca.pem --tlscert=cert.pem --tlskey=key.pem

Expose Docker API socket through SSH

To expose the Docker API socket through SSH, you need to make sure $DOCKER_HOSTis set on the remote host.

$ ssh -l <REMOTEUSER> <REMOTEHOST> 'echo $DOCKER_HOST'unix:///run/user/1001/docker.sock$ docker -H ssh://<REMOTEUSER>@<REMOTEHOST> run ...

Routing ping packets

On some distributions, ping does not work by default.

Add net.ipv4.ping_group_range = 0 2147483647 to /etc/sysctl.conf (or/etc/sysctl.d) and run sudo sysctl --system to allow using ping.

Exposing privileged ports

To expose privileged ports (< 1024), set CAP_NET_BIND_SERVICE on rootlesskit binary and restart the daemon.

$ sudo setcap cap_net_bind_service=ep $(which rootlesskit)$ systemctl --user restart docker

Or add net.ipv4.ip_unprivileged_port_start=0 to /etc/sysctl.conf (or/etc/sysctl.d) and run sudo sysctl --system.

Limiting resources

Limiting resources with cgroup-related docker run flags such as --cpus, --memory, --pids-limitis supported only when running with cgroup v2 and systemd.SeeChanging cgroup version to enable cgroup v2.

If docker info shows none as Cgroup Driver, the conditions are not satisfied.When these conditions are not satisfied, rootless mode ignores the cgroup-related docker run flags.SeeLimiting resources without cgroup for workarounds.

If docker info shows systemd as Cgroup Driver, the conditions are satisfied.However, typically, only memory and pids controllers are delegated to non-root users by default.

$ cat /sys/fs/cgroup/user.slice/user-$(id -u).slice/user@$(id -u).service/cgroup.controllersmemory pids

To allow delegation of all controllers, you need to change the systemd configuration as follows:

# mkdir -p /etc/systemd/system/user@.service.d# cat > /etc/systemd/system/user@.service.d/delegate.conf << EOF[Service]Delegate=cpu cpuset io memory pidsEOF# systemctl daemon-reload

Note

Delegating cpuset requires systemd 244 or later.

Limiting resources without cgroup

Even when cgroup is not available, you can still use the traditional ulimit andcpulimit,though they work in process-granularity rather than in container-granularity,and can be arbitrarily disabled by the container process.

For example:

  • To limit CPU usage to 0.5 cores (similar to docker run --cpus 0.5):docker run <IMAGE> cpulimit --limit=50 --include-children <COMMAND>

  • To limit max VSZ to 64MiB (similar to docker run --memory 64m):docker run <IMAGE> sh -c "ulimit -v 65536; <COMMAND>"

  • To limit max number of processes to 100 per namespaced UID 2000(similar to docker run --pids-limit=100):docker run --user 2000 --ulimit nproc=100 <IMAGE> <COMMAND>

Troubleshooting

Errors when starting the Docker daemon

[rootlesskit:parent] error: failed to start the child: fork/exec /proc/self/exe: operation not permitted

This error occurs mostly when the value of /proc/sys/kernel/unprivileged_userns_clone is set to 0:

$ cat /proc/sys/kernel/unprivileged_userns_clone0

To fix this issue, add kernel.unprivileged_userns_clone=1 to/etc/sysctl.conf (or /etc/sysctl.d) and run sudo sysctl --system.

[rootlesskit:parent] error: failed to start the child: fork/exec /proc/self/exe: no space left on device

This error occurs mostly when the value of /proc/sys/user/max_user_namespaces is too small:

$ cat /proc/sys/user/max_user_namespaces0

To fix this issue, add user.max_user_namespaces=28633 to/etc/sysctl.conf (or /etc/sysctl.d) and run sudo sysctl --system.

[rootlesskit:parent] error: failed to setup UID/GID map: failed to compute uid/gid map: No subuid ranges found for user 1001 ("testuser")

This error occurs when /etc/subuid and /etc/subgid are not configured. SeePrerequisites.

could not get XDG_RUNTIME_DIR

This error occurs when $XDG_RUNTIME_DIR is not set.

On a non-systemd host, you need to create a directory and then set the path:

$ export XDG_RUNTIME_DIR=$HOME/.docker/xrd$ rm -rf $XDG_RUNTIME_DIR$ mkdir -p $XDG_RUNTIME_DIR$ dockerd-rootless.sh

Note

You must remove the directory every time you log out.

On a systemd host, log into the host using pam_systemd (see below).The value is automatically set to /run/user/$UID and cleaned up on every logout.

systemctl --user fails with "Failed to connect to bus: No such file or directory"

This error occurs mostly when you switch from the root user to an non-root user with sudo:

# sudo -iu testuser$ systemctl --user start dockerFailed to connect to bus: No such file or directory

Instead of sudo -iu <USERNAME>, you need to log in using pam_systemd. For example:

  • Log in through the graphic console
  • ssh <USERNAME>@localhost
  • machinectl shell <USERNAME>@

The daemon does not start up automatically

You need sudo loginctl enable-linger $(whoami) to enable the daemon to startup automatically. SeeUsage.

iptables failed: iptables -t nat -N DOCKER: Fatal: can't open lock file /run/xtables.lock: Permission denied

This error may happen with an older version of Docker when SELinux is enabled on the host.

The issue has been fixed in Docker 20.10.8.A known workaround for older version of Docker is to run the following commands to disable SELinux for iptables:

$ sudo dnf install -y policycoreutils-python-utils && sudo semanage permissive -a iptables_t

docker pull errors

docker: failed to register layer: Error processing tar file(exit status 1): lchown <FILE>: invalid argument

This error occurs when the number of available entries in /etc/subuid or/etc/subgid is not sufficient. The number of entries required vary acrossimages. However, 65,536 entries are sufficient for most images. SeePrerequisites.

docker: failed to register layer: ApplyLayer exit status 1 stdout: stderr: lchown <FILE>: operation not permitted

This error occurs mostly when ~/.local/share/docker is located on NFS.

A workaround is to specify non-NFS data-root directory in ~/.config/docker/daemon.json as follows:

{"data-root":"/somewhere-out-of-nfs"}

docker run errors

docker: Error response from daemon: OCI runtime create failed: ...: read unix @->/run/systemd/private: read: connection reset by peer: unknown.

This error occurs on cgroup v2 hosts mostly when the dbus daemon is not running for the user.

$ systemctl --user is-active dbusinactive$ docker run hello-worlddocker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:385: applying cgroup configuration for process caused: error while starting unit "docker-931c15729b5a968ce803784d04c7421f791d87e5ca1891f34387bb9f694c488e.scope" with properties [{Name:Description Value:"libcontainer container 931c15729b5a968ce803784d04c7421f791d87e5ca1891f34387bb9f694c488e"} {Name:Slice Value:"user.slice"} {Name:PIDs Value:@au [4529]} {Name:Delegate Value:true} {Name:MemoryAccounting Value:true} {Name:CPUAccounting Value:true} {Name:IOAccounting Value:true} {Name:TasksAccounting Value:true} {Name:DefaultDependencies Value:false}]: read unix @->/run/systemd/private: read: connection reset by peer: unknown.

To fix the issue, run sudo apt-get install -y dbus-user-session or sudo dnf install -y dbus-daemon, and then relogin.

If the error still occurs, try running systemctl --user enable --now dbus (without sudo).

--cpus, --memory, and --pids-limit are ignored

This is an expected behavior on cgroup v1 mode.To use these flags, the host needs to be configured for enabling cgroup v2.For more information, seeLimiting resources.

Networking errors

This section provides troubleshooting tips for networking in rootless mode.

Networking in rootless mode is supported via network and port drivers inRootlessKit. Network performance and characteristics depend on the combinationof network and port driver you use. If you're experiencing unexpected behavioror performance related to networking, review the following table which showsthe configurations supported by RootlessKit, and how they compare:

Network driverPort driverNet throughputPort throughputSource IP propagationNo SUIDNote
slirp4netnsbuiltinSlowFast ✅Default in a typical setup
vpnkitbuiltinSlowFast ✅Default when slirp4netns isn't installed
slirp4netnsslirp4netnsSlowSlow
pastaimplicitSlowFast ✅Experimental; Needs pasta version 2023_12_04 or later
lxc-user-nicbuiltinFast ✅Fast ✅Experimental
bypass4netnsbypass4netnsFast ✅Fast ✅Note: Not integrated to RootlessKit as it needs a custom seccomp profile

For information about troubleshooting specific networking issues, see:

  • docker run -p fails with cannot expose privileged port
  • Ping doesn't work
  • IPAddress shown in docker inspect is unreachable
  • --net=host doesn't listen ports on the host network namespace
  • Newtork is slow
  • docker run -p does not propagate source IP addresses

docker run -p fails with cannot expose privileged port

docker run -p fails with this error when a privileged port (< 1024) is specified as the host port.

$ docker run -p 80:80 nginx:alpinedocker: Error response from daemon: driver failed programming external connectivity on endpoint focused_swanson (9e2e139a9d8fc92b37c36edfa6214a6e986fa2028c0cc359812f685173fa6df7): Error starting userland proxy: error while calling PortManager.AddPort(): cannot expose privileged port 80, you might need to add "net.ipv4.ip_unprivileged_port_start=0" (currently 1024) to /etc/sysctl.conf, or set CAP_NET_BIND_SERVICE on rootlesskit binary, or choose a larger port number (>= 1024): listen tcp 0.0.0.0:80: bind: permission denied.

When you experience this error, consider using an unprivileged port instead. For example, 8080 instead of 80.

$ docker run -p 8080:80 nginx:alpine

To allow exposing privileged ports, seeExposing privileged ports.

Ping doesn't work

Ping does not work when /proc/sys/net/ipv4/ping_group_range is set to 1 0:

$ cat /proc/sys/net/ipv4/ping_group_range1 0

For details, seeRouting ping packets.

IPAddress shown in docker inspect is unreachable

This is an expected behavior, as the daemon is namespaced inside RootlessKit'snetwork namespace. Use docker run -p instead.

--net=host doesn't listen ports on the host network namespace

This is an expected behavior, as the daemon is namespaced inside RootlessKit'snetwork namespace. Use docker run -p instead.

Network is slow

Docker with rootless mode usesslirp4netns as the default network stack if slirp4netns v0.4.0 or later is installed.If slirp4netns is not installed, Docker falls back toVPNKit.Installing slirp4netns may improve the network throughput.

For more information about network drivers for RootlessKit, seeRootlessKit documentation.

Also, changing MTU value may improve the throughput.The MTU value can be specified by creating ~/.config/systemd/user/docker.service.d/override.conf with the following content:

[Service]Environment="DOCKERD_ROOTLESS_ROOTLESSKIT_MTU=<INTEGER>"

And then restart the daemon:

$ systemctl --user daemon-reload$ systemctl --user restart docker

docker run -p does not propagate source IP addresses

This is because Docker in rootless mode uses RootlessKit's builtin portdriver by default, which doesn't support source IP propagation. To enablesource IP propagation, you can:

  • Use the slirp4netns RootlessKit port driver
  • Use the pasta RootlessKit network driver, with the implicit port driver

The pasta network driver is experimental, but provides improved throughputperformance compared to the slirp4netns port driver. The pasta driverrequires Docker Engine version 25.0 or later.

To change the RootlessKit networking configuration:

  1. Create a file at ~/.config/systemd/user/docker.service.d/override.conf.

  2. Add the following contents, depending on which configuration you would like to use:

    • slirp4netns

      [Service]Environment="DOCKERD_ROOTLESS_ROOTLESSKIT_NET=slirp4netns"Environment="DOCKERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER=slirp4netns"
    • pasta network driver with implicit port driver

      [Service]Environment="DOCKERD_ROOTLESS_ROOTLESSKIT_NET=pasta"Environment="DOCKERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER=implicit"
  3. Restart the daemon:

    $ systemctl --user daemon-reload$ systemctl --user restart docker

For more information about networking options for RootlessKit, see:

Tips for debugging

Entering into dockerd namespaces

The dockerd-rootless.sh script executes dockerd in its own user, mount, and network namespaces.

For debugging, you can enter the namespaces by runningnsenter -U --preserve-credentials -n -m -t $(cat $XDG_RUNTIME_DIR/docker.pid).

Run the Docker daemon as a non-root user (Rootless mode) (2024)

FAQs

How do I run a Docker container as a non root user? ›

Running Programs as non-root user, inside the Container
  1. Step 1: Create a Dockerfile. To write a Dockerfile. ...
  2. Step 2: Build an Image. To build an image from the Dockerfile. ...
  3. Step 3: Create and run a container from the previous step image. ...
  4. Step 4: Verify the user and ownership of the program running inside the container.
May 26, 2023

How do I make Docker run as non root? ›

Manage Docker as a non-root user

By default it's the root user that owns the Unix socket, and other users can only access it using sudo . The Docker daemon always runs as the root user. If you don't want to preface the docker command with sudo , create a Unix group called docker and add users to it.

Can Docker run in rootless mode? ›

How it works. Rootless mode executes the Docker daemon and containers inside a user namespace. This is very similar to userns-remap mode, except that with userns-remap mode, the daemon itself is running with root privileges, whereas in rootless mode, both the daemon and the container are running without root privileges ...

How to run Docker daemon without sudo? ›

Run Docker commands without sudo
  1. Add the docker group if it doesn't already exist. $ sudo groupadd docker.
  2. Add the connected user $USER to the docker group. Optionally change the username to match your preferred user. ...
  3. Restart the docker daemon. $ sudo service docker restart. ...
  4. Change the context from Docker Desktop to Engine.

How to create a non-root user? ›

Procedure
  1. To create the non-root user, type the following commands: useradd -c 'Admin User' -d /home/stiguser -m -s /bin/bash stiguser passwd stiguser. ...
  2. Edit the /etc/sudoers file. ...
  3. Verify that the new user can log in from a remote host and use the sudo command to become a root user.

Is Docker root or non-root? ›

Docker operates with root privileges, and being a member of the Docker group grants you virtual root access. When the Docker Unix socket is exposed to a container, it essentially bestows root privileges on the container, potentially granting it full access to the host system.

What is a rootless Docker? ›

The Rootless mode allows you to run the Docker daemon and containers as a non-root user. This mitigates the potential vulnerabilities in the daemon and the container runtime. As long as the prerequisites are met, rootless mode does not require root privileges even during the installation of the Docker daemon.

How do I know if Docker is rootless? ›

However, make sure you are using rootless docker before running this command. Test if you are indeed using rootless Docker by running docker info | grep "Docker Root Dir" . If the output contains /home/<username>/. local/share/docker then you are using rootless Docker.

How to run Docker as a different user? ›

To run a Docker container as a different user, we can use the –user option of the docker run command.

What are the disadvantages of rootless Docker? ›

Limitations. Unfortunately, rootless mode isn't perfect. The first issue is that rootless docker will not have access to privileged ports, which are any port below 1024. That means you'll need to remember to expose your containers to ports above 1024, otherwise, they will fail to run.

Should Docker run as root or user? ›

Processes in a Docker container should not be run as root. It's safer to run your applications as a non-root user which you specify as part of your Dockerfile or when using docker run . This minimizes risk by presenting a reduced attack surface to any threats in your container.

How do I run a Docker daemon? ›

Docker uses different binaries for the daemon and client. To run the daemon you type dockerd . To run the daemon with debug output, use dockerd --debug or add "debug": true to the daemon.json file.

Does Docker daemon does not require root privileges to run? ›

Rootless mode allows running the Docker daemon and containers as a non-root user, for the sake of mitigating potential vulnerabilities in the daemon and the container runtime. Rootless mode does not require root privileges even for installation of the Docker daemon, as long as the prerequisites are satisfied.

How to start Docker daemon using command? ›

How to Start the Daemon Manually?
  1. Open the terminal.
  2. Run the command “ sudo systemctl start docker “.
  3. The Docker daemon will begin running.
Apr 11, 2024

How to run Docker daemon in PowerShell? ›

Using Docker from PowerShell
  1. Launch a Windows PowerShell window.
  2. Add ssh.exe to your PATH: ...
  3. Create a new Docker VM. ...
  4. Get the environment commands for your new VM. ...
  5. Connect your shell to the my-default machine. ...
  6. Run the hello-world container to verify your setup.

How do I run a Docker container as a different user? ›

To run a Docker container as a different user, we can use the –user option of the docker run command.

How do I run a Docker container as a specific user? ›

Using the –user Option in docker run Command

This method permits us to assign the user while the container runs, and it's handy sometimes. The environment variables represent the user's UID and GID, which are applied to set the user in the container.

What is a rootless container? ›

In other words, rootless mode means that you can deploy a container without becoming root or using sudo . By default, Podman launches containers as the current regular user. Support for rootless containers is enabled for all newly created users in SLE by default, and no additional steps are necessary.

Top Articles
Latest Posts
Article information

Author: Frankie Dare

Last Updated:

Views: 6748

Rating: 4.2 / 5 (53 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Frankie Dare

Birthday: 2000-01-27

Address: Suite 313 45115 Caridad Freeway, Port Barabaraville, MS 66713

Phone: +3769542039359

Job: Sales Manager

Hobby: Baton twirling, Stand-up comedy, Leather crafting, Rugby, tabletop games, Jigsaw puzzles, Air sports

Introduction: My name is Frankie Dare, I am a funny, beautiful, proud, fair, pleasant, cheerful, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.