Open Gaming4LifeDE opened 3 years ago
I'm keen to add support for these; perhaps as two separate modules, plus a server operation, ie:
docker.container
(+docker.network
, etc)podman.container
(+anything relevant)server.container
that works like server.packages
- ie works with both docker & podman whichever is installedAre there any plans to add this to the project? Currently using ansible and was thinking of switching to pyinfra. But I heavily use the docker management commands from ansible.
Podman introduced Quadlet files in 4.4 to allow systemd to orchestrate containers declared in files. If you have a recent enough version of Podman, it is the recommended way and can be achieved with files.put
and systemd
operations. Simple example running nginx on port 8080:
from io import StringIO
from pyinfra.operations import apt, files, systemd
apt.packages(packages=["podman"])
spec = """
[Container]
Image=docker.io/nginx:1.25
PublishPort=8080:80
User=root
Group=root
PodmanArgs=--log-level=warn
[Service]
Restart=always
TimeoutStartSec=900
[Install]
WantedBy=multi-user.target default.target
"""
container = files.put(
name="Add test container quadlet",
src=StringIO(spec),
dest="/etc/containers/systemd/nginx.container",
)
if container.changed:
systemd.daemon_reload()
systemd.service(service="nginx.service", running=True, restarted=True)
Podman introduced Quadlet files in 4.4 to allow systemd to orchestrate containers declared in files
@xvello thanks, this sounds like a promising alternative for remote container management with pyinfra... I'm looking into using your approach + podlet to migrate a number of docker-compose based projects over.
Is your feature request related to a problem? Please describe
A lot of software requires docker-compose to be installed. So the workflow would be to deploy a server, install docker/podman and (docker/podman)-compose and then deploy your application using that
Describe the solution you'd like
An operation to manage docker/podman. The CLI syntax is the same so it shouldn't be much of an issue to support both. Running containers on boot is a different story though because docker has a daemon process and podman doesn't...