Running docker-compose inside distrobox on Fedora Silverblue

· Christopher Hoelter's Blog

How to run docker-compose inside a distrobox container on Fedora Silverblue and use the host podman as the container engine.

This will explain how to get docker-compose in an Ubuntu 22 distrobox working with podman on a Fedora Silverblue host. This assumes you have the Ubuntu distrobox up and running, and you've installed docker-compose from either the apt repository or downloading the binary and placing it in your distrobox users path.

First, on the Silverblue host you need to ensure the podman socket is enabled and running.

systemctl --user enable podman.socket
systemctl --user start podman.socket
systemctl --user status podman.socket

Next, inside your Ubuntu distrobox, ensure this variable is exported in your shell environment. The value '1000' should be whatever value running echo "$UID" on the Silverblue host gives you

1export DOCKER_HOST=unix:////run/host/run/user/1000/podman/podman.sock

Now, things may mostly just work, but we want to ensure all "docker" commands that run inside the distrobox are aliased to the podman binary on the Silverblue host. There are a couple things to account for with this.

To work around this, we'll create a small executable script with the name docker and place it in a directory that it's in the path of the distrobox user, but not in the path of the Silverblue host user. All this script does is pass any arguments invoked with the command docker to the host podman command.

1#!/usr/bin/env bash
2
3distrobox-host-exec podman "$@"

With all this in place, running docker-compose commands inside the distrobox container should function and use the Silverblue host podman as the container engine.


Please leave a comment or drop a message at https://lists.sr.ht/~hoelter/public-inbox. Email me directly at [email protected].