Linking containers through networks OMV 7

  • Hi,

    I am still quite new to OMV or setting up my own NAS in general but the last few months I have been working on (and struggling with) setting up docker and getting a mediaserver (Jellyfin) and cloud solution (Nextcloud) up and running via Nginx proxy manager.


    The reason it took me so long is that many tutorials and guides are (slightly) outdated or do not sufficiently explain (the importance of) networking in docker and how to do that in OMV7.

    So, after finally having a working setup, I want to post my setup and hopefully help someone, or get useful feedback to improve.


    By default, many containers create their own network in docker. To get it to communicate with the proxy manager, they need to be in the same network.

    So, for every network you want to use, you need to create it in the OMV GUI (Services -> Compose -> Networks)

    In this example I created the network "dockernet" and "nextcloud-aio" with 172.20.0.0/16 en 172.18.0.0/16 subnets (Set the Gateways accordingly, driver: bridge).


    In the compose files I need to make the container not create their own network, but connect to the network I created.

    This example of Jellyfin shows my settings in a configuration with nginx proxy manager.

    Jellyfin


    NGINX proxy manager (NPM)

    Note that I have connected NPM to two networks. Docker containers in the same docker network have all their ports to each other exposed, so I like Nextloud AIO separated from my other containers.


    Nextcloud-AIO

    Nextcloud-aio has a mandatory network: nextcloud-aio. Yes, the same network I created earlier, but I think it's important to configure like this. The declaration 'external: true' is to tell docker that the network is configured outside the container. I created the networks in the gui, so 'external: true' should be set here. Also in the other compose files.


    In this file I used "init: true" based on the docker docs. I am not sure if it's needed, but based on https://github.com/nextcloud/a…ne/blob/main/compose.yaml it makes sense to add it.

    In Nginx you can refer to Nextcloud by 'localhost' as in this guide that OMV-extras links to. I think you need this setting for it:

    APACHE_IP_BINDING=127.0.0.1

    In my nginx proxy host config I don´t use localhost, but the (network)name (use inspect) of nextcloud, in my case: nextcloud-aio-mastercontainer. I am not sure if this Apache setting is needed in my case. By disabling it NC seems to be working fine, but I don´t exactly know what I'm messing with. And I haven´t used NC very much yet to properly test.


    I hope this is useful to someone.

    Thank you for everyone working on OMV!

    Asus AM1M-A | AMD Athlon 5370 4 core | 8GB ram
    Drives: 32 GB | 120 GB | 4x 2TB
    Synology 213+
    Drives: 2x 1TB
  • crashtest

    Approved the thread.
    • Official Post

    many tutorials and guides are (slightly) outdated or do not sufficiently explain (the importance of) networking in docker and how to do that in OMV7.

    Maybe you didn't read this? --> https://wiki.omv-extras.org/doku.php?id=omv7:docker_in_omv


    By default, many containers create their own network in docker. To get it to communicate with the proxy manager, they need to be in the same network.

    So, for every network you want to use, you need to create it in the OMV GUI (Services -> Compose -> Networks)

    That's incorrect. If you read the previous document, you'll see that it's not necessary to assign a network to each container. It depends on your use case.

  • Quote

    probably > 50 times.


    following this guide and the other guides available I couldn´t get it to work in my use case (which is pretty standard, I think).


    I did however get it to work when I put NGINX and the service I want to run via NGINX in the same docker network. Following your guide I have every service running in their own network, and not being able to communicate with each other.


    So I tried the nginx example in linked guide once again and leaving out the network parts from my nginx compose file, omitting the following parts:

    Now nginx and the db are in the nginxpm_default network. Alone. So no service will work through nginx.


    What am I missing then? i do have the standard bridge network running, but the containers do not automatically connect to it. Apparently in your case they do, because the guide doesn´t mention docker networks or bridge networks at all.


    Cheers,

    Lennard.

    Asus AM1M-A | AMD Athlon 5370 4 core | 8GB ram
    Drives: 32 GB | 120 GB | 4x 2TB
    Synology 213+
    Drives: 2x 1TB
    • Official Post

    The wiki document is up-to-date; that's one of the advantages of having a live document that we update as new information becomes available.


    However, keep in mind that this document isn't intended to be a comprehensive Docker guide. Mastering Docker in depth requires much more documentation.


    If Docker networks aren't mentioned in this document, it's because they aren't necessary for typical use cases. In fact, I've had Nextcloud and Jellyfin in production for years, accessible via Nginx Proxy Manager, and I don't need to create a Docker network. I have the exact same configuration as in the wiki, without Docker networks. Communication with the proxy is done using each container's IP address and port; perhaps you should look into that. These containers don't need to communicate with each other.


    The situation is different if you use other proxies, where direct container communication is necessary. So, as I said, it depends on the use case.


    All Docker containers create their own Docker network. You only need it to be the same network if you need them to communicate with each other.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!