title: Provide static IP to docker containers via docker-compose
body: <p>I'm trying to provide static IP address to containers. I understand that I have to create a custom network. I create it and the bridge interface is up on the host machine (Ubuntu 16.x). The containers get IP from this subnet but not the static I provided.</p>
  
  <p>Here is my docker-compose.yml:</p>
  
  <pre><code>version: '2'
  
  services:
    mysql:
      container_name: mysql
      image: mysql:latest
      restart: always
      environment:
        - MYSQL_ROOT_PASSWORD=root
      ports:
       - "3306:3306"
      networks:
       - vpcbr
  
    apigw-tomcat:
      container_name: apigw-tomcat
      build: tomcat/.
      ports:
       - "8080:8080"
       - "8009:8009"
      networks:
       - vpcbr
      depends_on:
       - mysql
  
  networks:
    vpcbr:
      driver: bridge
      ipam:
       config:
         - subnet: 10.5.0.0/16
           gateway: 10.5.0.1
           aux_addresses:
            mysql: 10.5.0.5
            apigw-tomcat: 10.5.0.6
  </code></pre>
  
  <p>The containers get 10.5.0.2 and 10.5.0.3, instead of 5 and 6.</p>