I think what you’re describing can be accomplished with docker-compose’s depends_on option. I’m not certain how it works across compose files, but that would be the first place I’d look.
Self Hosted - Self-hosting your services.
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
- No harassment
- crossposts from c/Open Source & c/docker & related may be allowed, depending on context
- Video Promoting is allowed if is within the topic.
- No spamming.
- Stay friendly.
- Follow the lemmy.ml instance rules.
- Tag your post. (Read under)
Important
Beginning of January 1st 2024 this rule WILL be enforced. Posts that are not tagged will be warned and if not fixed within 24h then removed!
- Lemmy doesn't have tags yet, so mark it with [Question], [Help], [Project], [Other], [Promoting] or other you may think is appropriate.
Cross-posting
- !everything_git@lemmy.ml is allowed!
- !docker@lemmy.ml is allowed!
- !portainer@lemmy.ml is allowed!
- !fediverse@lemmy.ml is allowed if topic has to do with selfhosting.
- !selfhosted@lemmy.ml is allowed!
If you see a rule-breaker please DM the mods!
Yeah..seems like the depends_on works with multiple services in one single compose file..and putting 10 services in tha same compose file is messy
You can split services into multiple YAML files (i.e. docker-compose.database.yml
and docker-compose.backend.yml
or whatever) and then use docker compose up -d docker-compose.database.yml docker-compose.backend.yml
. Compose treats this like it would one file internally (i.e. the services are connected to each other via an internal network by default).
I feel like I'm missing something here. I've never needed to worry about docker container IPs.
I wonder why you want them to have fixed IPs. I guess I want to understand the problem it would solve.
If all you want to do is have the other containers use the pihole as DNS.. they'd already be doing so if the server is using it as the DNS server.
At worst you'd need to provide
dns:
- <server IP where pihole is>
property to the services.
Maybe I'm the one missing something. Are you saying I just have to use the LAN IP adress in the dns line in the compose file? I used the docker IP adress because I had some issues with containers not communicating with each other because every time I create a new container docker creates a new network for it. I'm gonna give it a try once I get home. Thanks!
It worked! Thanks mate! I just removed the IP address and changed to hostnames and everything worked beautifully!
Hello, I think you would prefer to connect via internal dns names rather than static IPs. I have a slightly similar setup with docker compose creating a network for my apps.
Docker compose that creates the network: https://github.com/HugoKlepsch/reverse-proxy-network/blob/master/docker-compose.yaml
Here I run my app and set the hostname. Note this app is on two docker networks, but for access from nginx it is on the “reverse_proxy” network: https://github.com/HugoKlepsch/buzz/blob/b160aab1649819acacb80964d7b19d7beb1712f6/docker-compose.yaml#L21
This compose is running nginx as a reverse proxy for my local apps. It uses the reverse proxy network: https://github.com/HugoKlepsch/reverse-proxy/blob/675e11d3d8a98e4692c6e6087de4428ac8d1ece8/docker-compose.yaml#L4
Here is a configuration file where I tell nginx where to find one of my apps on the reverse proxy docker network. Note the name references the name of the app and the docker network: https://github.com/HugoKlepsch/reverse-proxy/blob/675e11d3d8a98e4692c6e6087de4428ac8d1ece8/config/conf.d/sites-available/buzz.conf#L2
Wow what a reply! Thank you so much! I could set up all containers using the pihole as DNS using hostnames..your post helped me a lot!
Maybe not exactly what you are looking for but with Podman you can run any Docker container and control it via normal Systemd service files including all the fine grained control options that come with that.