Docker compose yml static IP addressing : <p>I have such docker-compose.yml (not a full list here):</p>

<pre><code>version: '2'

services:

  nginx:
    build: ./nginx/
    ports:
      - 8080:80
    links:
      - php
    volumes_from:
      - app
    networks:
      app_subnet:
        ipv4_address: 172.16.1.3

  php:
    build: ./php/
    expose:
      - 9000
    volumes_from:
      - app
    networks:
      app_subnet:
        ipv4_address: 172.16.1.4

    networks:
      app_subnet:
        driver: bridge
        ipam:
        config:
          - subnet: 172.16.1.0/24
          gateway: 172.16.1.1
</code></pre>

<p>After <code>docker-compose up</code> I got such an error:</p>

<blockquote>
  <p>User specified IP address is supported only when connecting to
  networks with user configured subnets</p>
</blockquote>

<p>So I'm creating subnet with <code>docker network create --gateway 172.16.1.1 --subnet 172.16.1.0/24 app_subnet</code></p>

<p>But this doesn't solve the problem because docker-compose creates the subnet with name dev_app_subnet on the fly. And my subnet is not used - I'm getting the same error. 
The main purpose of doing this is to assign static IP for nginx service - open my project web url from etc/hosts file.</p>
