Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Need auto start container when use --restart=always #9

Open
BlackHole1 opened this issue Jun 17, 2024 · 2 comments

Comments

@BlackHole1
Copy link
Member

When a container is started with restart=always, it will not automatically start if the system or WSL is rebooted.

@ihexon
Copy link
Collaborator

ihexon commented Jun 17, 2024

That's interesting, podman appears to use systemd to implement the restart policy like this:

[Unit]
Description=A templated sleepy container

[Container]
Image=quay.io/fedora/fedora
Exec=sleep %i

[Service]
# Restart service when sleep finishes
Restart=always

[Install]
WantedBy=multi-user.target
DefaultInstance=100

Maybe we need a minimal init to take over our service just like systemd !

BTW, In theory we can take over the WSL2 init and make our init run as PID 1, but it's a bit of a hack, I'll try it.

@BlackHole1
Copy link
Member Author

That's interesting, podman appears to use systemd to implement the restart policy like this:

See: https://github.com/containers/podman/blob/main/contrib/systemd/system/podman-restart.service.in

There are two ways to manage restart=always in podman. The first way is as you mentioned, by creating a systemd service for each container. The other way is the method I just mentioned, which uses a single systemd service to manage all containers with restart=always.

Maybe we need a minimal init to take over our service just like systemd !

Yes

BTW, In theory we can take over the WSL2 init and make our init run as PID 1, but it's a bit of a hack, I'll try it.

Please No! Hacking methods are always our last resort; their priority is always the lowest, and they will only be considered when there are no other ways to solve the problem.
Please investigate other solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants