You probably want to look into Health Checks. I believe you can tell Docker to "start service B when service A is healthy", so you can define your health check with a script that depends on Tailscale functioning.
Selfhosted
A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.
Rules:
-
Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.
-
No spam posting.
-
Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.
-
Don't duplicate the full text of your blog or github here. Just post the link for folks to click.
-
Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).
-
No trolling.
Resources:
- selfh.st Newsletter and index of selfhosted software and apps
- awesome-selfhosted software
- awesome-sysadmin resources
- Self-Hosted Podcast from Jupiter Broadcasting
Any issues on the community? Report it using the report flag.
Questions? DM the mods!
This is the correct answer, but you need a few things to clarify:
- The issue isn't the Docker system service. Don't make that depend on Tailscale
- Add a healthcheck and restart policy to the container to make it fail when conditions aren't met, and restart until they are successful
- Build in some time tolerance at the service level inside the container to prevent it from flailing if your Tailscale healthchecks don't pass after they initially start. Don't rely solely on container health checks to ensure it works properly as that might not always be possible.
Considering it's tailscale, one may want to have the service fail though as tailscale is sometimes not used for convenience but security concerns instead.
I need to figure this out on my immich stack. VM reboot only starts two out of the 4 services. Ty for the info.
Delay the start of your containers with the tailscale dependency. Are you using required or depends_on in your docker-compose.yml
https://hatchjs.com/docker-compose-conditionally-start-service/
If you're using kubernetes you can make the requirements at the pod level
https://stackoverflow.com/questions/69423932/container-initialization-order-in-pod-on-k8s
Edit: If using docker-compose.yml you can set a condition on a healthcheck
You can also specify a condition that must be met before the service is started. For example, the following configuration will start the web
service only if the db
service is healthy:
version: ‘3.7’
services:
web:
image: nginx
depends_on:
– db
condition: service_healthy
The service_healthy
condition checks the health of the db
service using the docker-compose ps
command. If the db
service is healthy, the web
service will be started.