You are root by default in this environment! Which means less work for ITs 😇
Also, the possibility of using software that is newer than the base system.
- You must install
newuidmapandnewgidmapon the host. These commands are provided by theuidmappackage on most distros. /etc/subuidand/etc/subgidshould contain at least 65,536 subordinate UIDs/GIDs for the user. In the following example, the usertestuserhas 65,536 subordinate UIDs/GIDs (231072-296607).
Note
If the system-wide Docker daemon is already running, consider disabling it:
$ sudo systemctl disable --now docker.service docker.socket $ sudo rm /var/run/docker.sockShould you choose not to shut down the
dockerservice and socket, you will need to use the--forceparameter in the next section. There are no known issues, but until you shutdown and disable you're still running rootful Docker.
If you installed Docker 20.10 or later with RPM/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:$PATH
export DOCKER_HOST=unix:///run/user/YOUR_UID_HERE/docker.sockIf 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
See Troubleshooting if you faced an error.
There are two options:
-
Download the original distrobox
Please refer to the Distrobox installation page. You also have to download the patch file at distrobox-rootless.patch.
After downloading, run the patch command to patch the executables:
cd ~/.local/bin patch < distrobox-rootless.patch -
Use the version provided in this repo
Simply git clone this repo. It already works ot of the box 🙃
For more usage please reference the official docs at distrobox.it. We only show you some useful examples:
distrobox create --image ubuntu:24.04 --name "YOUR CONTAINER NAME" --hostname "YOUR HOSTNAME" --nvidia --volume "SRC_ON_HOST:TARGET_PATH_IN_CONTAINER"
-
--nvidiais required for nvidia integration with docker. -
--volumeis a flag for mounting additional folders inside the container.
distrobox enter "YOUR_CONTAINER_NAME"
If you plan on continue running the docker container after you log out, and you don't want systemd to kill all processes under
user*.slice, there are two options:
- leave a tmux session open on the host (since there is at least one user logged in the system, systemd won't kill the user session).
- use
loginctl enable-lingeron the current user.