Hi guys! I have several docker containers running on my home server set up with separated compose files for each of them, including a Pihole one that serves as my home DNS. I created a network for it and a fixed IP but I couldn’t find a way to set fixed IPs to the other containers that use the Pihole network. Well everything works but every now and then I have problems because the Pihole cant start first and grab the fixed IP and some other container gets its IP so nothing works because everything depends on the Pihole to work. My Pihole compose is like this:

`networks: casa:

driver: bridge
ipam:
  config:
    - subnet: "172.10.0.0/20"

networks:

  casa:
    ipv4_address: 172.10.0.2`

My Jellyfin container as an example is like this:

`_networks: - pihole_casa dns: - 172.10.0.2

networks: pihole_casa: external: true__`

I read the documentation about setting fixed IP but all I got was using one single compose file and with 12 containers that seems like a messy solution… I couldn’t set fixed IPs with different compose files. Do you guys have any suggestion about it?

Thanks!

TLDR: I want to set fixed IPs to containers in different compose files so all of them use Pihole as DNS and don´t steal Pihole’s IP in the startup

  • 𝙚𝙧𝙧𝙚@feddit.win
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    2 years ago

    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.

    • fernandu00@lemmy.mlOP
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

      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!

    • fernandu00@lemmy.mlOP
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      It worked! Thanks mate! I just removed the IP address and changed to hostnames and everything worked beautifully!