Page MenuHomeVyOS Platform

Containers: Add 'Requires' and 'After' as container opttions
Open, NormalPublicFEATURE REQUEST

Description

Sometimes containers are dependent on other containers. Since VyOS uses systemd to run the containers, this can be accomplished with adding Requires and After as options in the container config.

  • Requires 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.

Syntax could be something like (note multi should be used):

set container name alpine dependency requires <container-a>
set container name alpine dependency requires <container-b>
set container name alpine dependency after <container-a>
set container name alpine dependency after <container-b>

Details

Version
-
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Feature (new functionality)

Event Timeline

L0crian renamed this task from Containers: Add 'Requires' and 'After' to Containers: Add 'Requires' and 'After' as container opttions.

What about option priority?

set container name c1 priority 1
set container name c2 priority 2
Viacheslav triaged this task as Normal priority.Sep 1 2025, 4:06 PM

What about option priority?

set container name c1 priority 1
set container name c2 priority 2

Do you mean to manipulate the start order of the containers? If so, I don’t think it’d solve the issue. On a suitably fast system, all of the containers would start within a fraction of a second of each other. So it’d be a race condition that would almost always fail.

After and Requires are actual fields in the Podman Quadlet that'll create hard dependencies on the other containers being up:

Ex.
[Unit]
Description=VyOS Container SomeContainer
Requires=vyos-container-db.service vyos-container-cache.service
After=vyos-container-db.service vyos-container-cache.service

There's also "Wants" that could be added, which is a weak dependency, and would just create a message in the log that the dependent service wasn't present.

It might also be useful to add the "healthchecks" option as part of the podman run arguments. That way if the container doesn't have it's own healthchecks, or the user wanted to add to them, they'd have that option. Then Restart=on-failure would actually have something to hook to.