Docker-Compose Podman
Tuesday, 23 November 2021Prerequisites
- docker-compose
- A Linux host – I use a Debian 11 KVM virtual machine
- Time
Setup
There are two routes here that I considered.
Use Podman from Debian
This should work just fine, but I would make sure that there isn’t a feature you are missing out on due to running Debian’s older version. Check Podman’s release page against Debian’s package version. At the time of this writing, it is a matter of version 3.3.0 vs 3.0.1.
This method is quite simple, just run apt install podman
(what I did) Use Kubic’s Podman package
I found the Kubic Package Repository for Podman on Podman’s install page. I noticed that there are repositories for not only Ubuntu, but Centos, Debian, Fedora, and Raspbian too.
To use this with Debian 11, run the following as root
…
echo 'deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_11/ /' | sudo tee /etc/apt/sources.list.d/podman.list
curl -LSs https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_11/Release.key | sudo apt-key add -
Configuration
For the most part, you have a pretty sane Podman setup at this point. You should be able to run podman
commands just fine. I did perform one optimization and some additional setup to accommodate the migration from docker-compose.
(optional) Change the Storage Driver
By default, Podman uses the overlay
storage driver. I use BTRFS as my file system for Linux systems so I would like to leverage its builtin features for container storage.
Open /etc/containers/storage.conf
with your favorite editor and change the line, driver = "overlay"
to driver = "btrfs"
.
sed -i 's/^driver *= *.*/driver = "btrfs"/' /etc/containers/storage.conf
This is a one line solution too.
Run man containers-storage.conf
for more details and other drivers you might be interested in.
Enable systemd Units for Docker API support
podman.socket
– This is what provides the Docker API Unix domain socket at/var/run/podman/podman.sock
podman.service
– This is a direct dependency ofpodman.socket
and provides the Podman API.podman-restart.service
– This makes sure that containers with a restart policy set are restarted.
To enable all of the above…
systemctl enable --now podman.socket podman.service podman-restart.service
docker-compose up -d
To run your docker-compose.yml
with your project with docker-compose
, you will need to export the following to your shell…
export DOCKER_HOST="unix:///var/run/podman/podman.sock"
This tells the docker-compose
command to speak to the Podman socket.
Now, execute docker-compose up -d
, your containers should now be up and running. Verify by running podman ps
.
Prologue
You now have a system using Podman with docker-compose!
Next steps will be migrating to something like a Kubernetes YAML or systemd unit files.
re: podman generate