You can set it as systemd socket service, so it doesn’t even run until something tries to connect.
That said, I don’t even bother with that. Podman can run K8s configs, and they are yaml too, only slightly more verbose than a compose file, if you strip everything out you don’t need. The CLI is nicer than compose too, with proper commands instead of tying up a terminal until a ctrl-c.
There's apparently a 'podman play kube' command that can take some k8s yaml like pod descriptions and instantiate them directly: https://docs.podman.io/en/latest/markdown/podman-play-kube.1... I hadn't heard of this until now but it sounds pretty nifty!
I honestly wouldn't put much faith in swarm being viable for long. Mirantis basically stopped working on it before they broke docker apart. The current docker company seems much more focused on developer experience tooling, not distributed systems. There are some longstanding swarm issues and bugs, particularly with changing configurations or one time jobs, that will probably never be fixed. I'd go straight to kubernetes and skip swarm personally. Stuff like k3s make kubernetes much easier to deploy at a small scale. Or I'd look at Hashi's nomad if something about k8s was really a blocker.
and get a rootless, Docker-compatible socket. If you're running, e.g., a test suite written against the Go Moby APIs, this will execute the containers with Podman rather than with the system daemon.
That said, I don’t even bother with that. Podman can run K8s configs, and they are yaml too, only slightly more verbose than a compose file, if you strip everything out you don’t need. The CLI is nicer than compose too, with proper commands instead of tying up a terminal until a ctrl-c.