compose icon indicating copy to clipboard operation
compose copied to clipboard

How to bind a multiple public ip to docker?

Open YuriyTigiev opened this issue 3 years ago • 1 comments

How to bind a multiple public IP to docker? For example on the host machine I have three different public ip 45.148.28.67, 45.148.31.170, 45.148.31.172 NodeJs Web App from docker will use these IP addresses for making https requests. The web app supports to send request from different ip - agent: new https.Agent({ localAddress: ip, port: 443, keepAlive: true }). Is not clear how to modify existing docker-compose file to get access to publics IP on the host machine for the web app?

services:
  backend:
    build: .
    ports:
      - 80:3000
      - 9229:9229 # debugger port
    volumes:
      - .:/usr/src/app
      - /usr/src/app/node_modules
    depends_on:
      - redis
    command: yarn start:docker
    environment:
      PORT: 80

  redis:
    image: redis:6.0.16-alpine
    privileged: true
    ports:
      - 6379:6379
    volumes:
      - ${PWD}/data/redis:/data
      #  - ${PWD}/redis.conf:/usr/local/etc/redis/redis.conf
      - ${PWD}/redis.conf:/etc/redis.conf
    depends_on:
      - influxdb

  influxdb:
    image: influxdb:latest
    volumes:
      # Mount for influxdb data directory and configuration
      - ${PWD}/data/influxdb:/root/.influxdb2:rw
    ports:
      - "8086:8086"

networks:
  company_internal_net:
    driver: "bridge"

Netwotk config

br-579c572a3ea3: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.21.0.1  netmask 255.255.0.0  broadcast 172.21.255.255
        ether 02:42:25:50:70:a5  txqueuelen 0  (Ethernet)
        RX packets 511535  bytes 240787148 (229.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 511535  bytes 240787148 (229.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

br-5e68534f6f9a: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.18.0.1  netmask 255.255.0.0  broadcast 172.18.255.255
        ether 02:42:5e:5a:5a:f6  txqueuelen 0  (Ethernet)
        RX packets 511537  bytes 240787285 (229.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 511537  bytes 240787285 (229.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

br-aa1b007e6aed: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.24.0.1  netmask 255.255.0.0  broadcast 172.24.255.255
        inet6 fe80::42:5ff:fe58:330d  prefixlen 64  scopeid 0x20<link>
        ether 02:42:05:58:33:0d  txqueuelen 0  (Ethernet)
        RX packets 511537  bytes 240787285 (229.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 511537  bytes 240787285 (229.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        inet6 fe80::42:20ff:fe94:d4fc  prefixlen 64  scopeid 0x20<link>
        ether 02:42:20:94:d4:fc  txqueuelen 0  (Ethernet)
        RX packets 2759  bytes 225996 (220.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3493  bytes 16091560 (15.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 45.148.28.67  netmask 255.224.0.0  broadcast 45.159.255.255
        inet6 2a06:1301:4050:45:148:31:170:0  prefixlen 56  scopeid 0x0<global>
        inet6 fe80::216:3eff:fe3a:4bee  prefixlen 64  scopeid 0x20<link>
        inet6 2a06:1301:4050:45:148:28:67:0  prefixlen 56  scopeid 0x0<global>
        inet6 2a06:1301:4050:45:148:31:172:0  prefixlen 56  scopeid 0x0<global>
        ether 00:16:3e:3a:4b:ee  txqueuelen 1000  (Ethernet)
        RX packets 109635093  bytes 9404006439 (8.7 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2904997  bytes 714376219 (681.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 45.148.31.170  netmask 255.224.0.0  broadcast 45.159.255.255
        ether 00:16:3e:3a:4b:ee  txqueuelen 1000  (Ethernet)

eth0:2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 45.148.31.172  netmask 255.224.0.0  broadcast 45.159.255.255
        ether 00:16:3e:3a:4b:ee  txqueuelen 1000  (Ethernet)

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 511539  bytes 240787515 (229.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 511539  bytes 240787515 (229.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth4de3a42: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::5028:54ff:fe43:32a1  prefixlen 64  scopeid 0x20<link>
        ether 52:28:54:43:32:a1  txqueuelen 0  (Ethernet)
        RX packets 103087  bytes 85121771 (81.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 117556  bytes 32151099 (30.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethf11f701: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::4c77:f4ff:feed:9771  prefixlen 64  scopeid 0x20<link>
        ether 4e:77:f4:ed:97:71  txqueuelen 0  (Ethernet)
        RX packets 314782  bytes 3854491634 (3.5 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 343760  bytes 4119190129 (3.8 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

YuriyTigiev avatar Mar 14 '22 18:03 YuriyTigiev

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 21 '22 10:09 stale[bot]

This issue has been automatically closed because it had not recent activity during the stale period.

stale[bot] avatar Nov 02 '22 03:11 stale[bot]