大网数据广告活动
服务器运维问答

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

· 52CE 我爱测

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 rel…

问题原文

原帖链接 · Marcus Müller · CC BY-SA 4.0

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?

已采纳解答

原帖链接 · Erik Sjölund · CC BY-SA 4.0

Update 2024 April 11

The command-line tool podlet generates podman quadlet files from a podman command or a compose file.

The command podman generate systemd is deprecated. The Podman development team now recommends using quadlet files instead (see podman-systemd.unit(5)). These files are automatically converted to systemd service units by /usr/libexec/podman/quadlet by the method described in systemd.generator(7)

Old answer

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-04-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。