Docker communication betweend containers

    • Docker communication betweend containers

      New

      Hello

      I have installed docker-gui from omv-extras on my OMV 3.0 system.
      I can successfully download images and create containers from them.
      However, I would like to create two containers and communicate between the two and I fail to do so.

      Specifically, I would like to create the library/mariadb and zabbix/zabbix-server-mysql containers. Later I would like to add the WebGUI too.
      Now one container is the server and one is the SQL-DB server, so obviously the server needs to talk to the SQL-DB server.

      Since I wouldn't like to expose the whole SQL-DB server to my other clients on the network, I tried to create both containers on the bridge network interface of docker. On the mariadb container, I exposed TCP/3306 like this:




      Now in the server container I need to provide the hostname or IP of the SQL-DB server as environment variable. How would I best do this? I don't know the IP-Address of the container until it is started, and even then it wouldn't be guaranteed to be static. Using hostname doesn't seem to work, even when "Host name" field is supplied in the above screenshot. The name cannot be resolved and is not added under /etc/hosts.

      Any ideas?


      System
      Linux nas 4.9.0-0.bpo.3-amd64 #1 SMP Debian 4.9.30-2+deb9u2~bpo8+1 (2017-06-27) x86_64 GNU/Linux

      docker version
      Client:
      Version: 17.05.0-ce
      API version: 1.29
      Go version: go1.7.5
      Git commit: 89658be
      Built: Thu May 4 22:04:27 2017
      OS/Arch: linux/amd64

      Server:
      Version: 17.05.0-ce
      API version: 1.29 (minimum version 1.12)
      Go version: go1.7.5
      Git commit: 89658be
      Built: Thu May 4 22:04:27 2017
      OS/Arch: linux/amd64
      Experimental: false


      default bridge
      docker0 Link encap:Ethernet HWaddr 02:42:3f:28:60:23
      inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
      UP BROADCAST MULTICAST MTU:1500 Metric:1
      RX packets:6571 errors:0 dropped:0 overruns:0 frame:0
      TX packets:8685 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:583133 (569.4 KiB) TX bytes:4495922 (4.2 MiB)
    • New

      Not literally the same address, but docker creates a port forwarding rule on the nat table so when you reach the requested port at host, iptables will reach the assigned IP address of the container on the bridge. Just look at the iptables nat table.
      chat support at #openmediavault@freenode IRC | Spanish & English | GMT+10
      telegram.me/openmediavault broadcast channel
      openmediavault discord server
    • Users Online 2

      2 Guests