podman + docker compose and daemon on Linux
I'm setting up my developer machine and this is a common situation I face working on some opensource projects. Podman itself already is a great replacement for all container needs I have but docker compose still is an important component. In this post, I want to go through the process to setup a Fedora machine using Podman with support for docker compose.
Requirements
Some new Linux distro. Even Debian Testing will have the necessary packages. Here, I'm using Fedora 42.
Install the necessary OS packages
Install podman and it's alias for docker:
# For CentOS Stream or Fedora
sudo dnf install podman podman-docker
# Test if it works
podman run -it --rm ubi9
docker run -it --rm alpine
podman image ls
docker image ls
# If that worked, that mean both podman and docker
# points to the same applicationinstall podman
Enable the podman daemon
Depending how you setup your environment, by default the "docker daemon" will be used by the docker compose. Podman offers a daemon compatible with it out-of-the-box. Let's enable it:
If you don't do that, it is common to see the following error message:Cannot connect to the Docker daemon at unix:///run/user/1000/podman/podman.sock. Is the docker daemon running?
# Enable and start the podman socket
# (do not run this as root)
systemctl --user enable podman.socket
systemctl --user start podman.socket
# Check if it worked
systemctl --user status podman.socketenable a local-user podman socket
Download the latest compose
The docker compose is a plugin for the main CLI itself. Podman is able to consume and interface with it as well.
First, go to the release page and grab the latest version:
Then, download it to your machine:
# Remember to check the latest version. This probably is an older version
COMPOSE_VERSION=v2.37.0
DOCKER_CONFIG=${DOCKER_CONFIG:-${HOME}/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
chmod +x $DOCKER_CONFIG/cli-plugins/docker-composedownload docker compose
And that's it! You can test it now:
docker compose --helpcheck if docker compose is available