Podman: Method to convert docker-compose files to systemd unit files

I'm migrating away from docker towards podman (not going straight for kubernetes, as that would definitely be overkill at this point).

Now, many an elegant configuration can be had as docker-compose setup – but docker-compose relies on the docker daemon to start (and keep running) the interdependent containers.

The podman way of doing that would be by having systemd unit files that depend on each other and let systemd do the monitoring, and startup (and shutdown).

Now, hand-converting docker-compose setups to unit files is error-prone, and slightly tedious.

Is there a known source of a sensible docker-compose compatible reader that I can set up to generate systemd unit files?


Solution 1:

Podman 3.0 (released in February 2021) introduced support for the standard docker-compose. Podman now supports the Docker REST API well enough to be able to serve the needs of docker-compose.

Although I haven't tested it, I hope the following method could be a way to convert docker-compose YAML to systemd service files:

  1. Start docker-compose
export DOCKER_HOST=unix:///some/path/podman.sock
docker-compose up -d

(I wrote another Stackoverflow answer with more details)

  1. Try to identify the names of the Podman containers that docker-compose started:
podman container list
  1. Generate systemd service files from these containers
podman generate systemd --new --files --name containername

(see the man page)

The article From Docker Compose to Kubernetes with Podman discusses a related topic: How to convert Docker Compose YAML to Kubernetes YAML.