TransWikia.com

Running a process under systemd init for containerization?

Unix & Linux Asked on December 6, 2021

Docker provides for the ability to run a command when the container starts. This is specified with CMD in the Dockerfile.

However, if I want my container to start with systemd I have to use,

CMD ["/usr/sbin/init"]

Only then is init in ps1. If this is required, is CMD of any use? Is there anyway to start systemd, and have it start another process too from the command line, or what podman run specifies?

There are multiple different dumb init processes for containerization like, catatonit, dumb-init, and tini but they’re all "dumb". I want a real systemd init with the ability to specify the process after the default.target is hit.

One Answer

You’re using CMD to configure your container to start systemd, so it seems to me it is “useful”.

To start another command in your container, either:

  • on the command line, use docker exec;
  • in the container definition, use a systemd service.

Answered by Stephen Kitt on December 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP