How to handle container priority or dependency

If some containers depend on each other, how can I ensure they start in the correct order? If that’s not possible, I’m fine with disabling auto-start on boot.

thanks!

Unfortunately, I don’t think there’s a “good” way to do it.

The containers default to an on-failure restart policy, so best case if the parent container isn’t up yet, then the child container will restart until it works. This would require the child container to actually fail, and not simply just not work.

You could of course script this so that post-boot and post-commit, the child container does a podman container inspect of the parent, and restarts itself if needed depending on: a) The parent isn’t healthy and/or b) the child isn’t working correctly.

You can also override the entrypoint in the child containers, and apply a sleep timer before the entrypoint is executed. Hopefully allowing time for the parent to come up.

This does bring up the idea of a useful feature request though. Since VyOS builds containers into a systemd service, it can add Require and `After fields.

  • Require means that a container is tied to another container. So if you reboot the parent container, then it’ll reboot any container that says it requires that parent.
  • After will only start the child if the parent is “up” first. This may or may not help, because it’s not checking if whatever the parent is doing is present, just that the service is healthy.

I’ll go ahead and generate a feature request for that.

Here’s the Task for the feature request: ⚓ T7769 Containers: Add 'Requires' and 'After'

1 Like

Containers started in alphanumeric sequences.

You can rename containers to check.

1 Like

thank you and viacheslav!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.