Assign different IPs to different Docker container

I need to run two containers each containing a script binding on a specific (public) IP (11.11.11.22 and 11.11.11.23)

The docker host itself is on 10.10.10.222.

  • Docker IIS Network Connection to External Network
  • Docker Machine could not reach ip address/machine successfully using hyperv
  • How can I edit files in a docker container when it's down/not-started
  • Persistent Java Application Server profile in docker [closed]
  • Restart Docker Container (Automatically) when Image changes in Portainer(?)
  • AngularDart build with Docker
  • I have the subnet 11.11.11.20/27, my gateway is 11.11.11.21

    If it matters my server is at SoftLayer.

    docker-compose.yml

    version: '2'
    services:
      nginx-0:
        image: nginx:1.10
        ports:
          - 11.11.11.22:80:80
        networks:
          app_net:
            ipv4_address: 11.11.11.22
    
      nginx-1:
        image: nginx:1.10
        ports:
          - 11.11.11.23:80:80
        networks:
          app_net:
            ipv4_address: 11.11.11.23
    
    networks:
      app_net:
        driver: bridge
        ipam:
          driver: default
          config:
          - subnet: 11.11.11.20/27
            gateway: 11.11.11.21
    

    ip a


    3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
        link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
        inet 10.10.10.222/27 brd 10.10.10.223 scope global eth1
           valid_lft forever preferred_lft forever
        inet 11.11.11.22/32 brd 11.11.11.22 scope global eth1:0
           valid_lft forever preferred_lft forever
        inet 11.11.11.23/32 brd 11.11.11.23 scope global eth1:1
           valid_lft forever preferred_lft forever
    

    ips inside container docker exec nginx-0 ip a

    6: eth0@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
        link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
        inet 11.11.11.22/27 scope global eth0
           valid_lft forever preferred_lft forever
    

    If I curl the two IPs i get an “curl: (52) Empty reply from server”

    Any other IP in my range will return “Failed to connect…”

    Is there any solution to do this?

    Thanks in advance!
    Dominik

  • Docker Registrator: Connection refused
  • Gearmand Does Not Start - Socket Address Family Not Supported
  • Supervisor is not starting up
  • How to watch xvfb session that's inside a docker on remote server from my local browser?
  • Deploying Docker to AWS Elastic Beanstalk — how to forward port to host? (port binding)
  • Docker: Error processing tar file(exit status 1): Error setting up pivot dir: not a directory
  • One Solution collect form web for “Assign different IPs to different Docker container”

    I figured it out.

    I had to remove the interface on the host.

    ipconfig eth0:0 down
    ipconfig eth0:1 down
    

    I also removed it from the /etc/networking/interfaces

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.