Docker-compose network not used during override

docker

I have a docker-compose file that I extend using an override. I'm using V2 syntax and in my compose file I define a network that two containers will share. I then extend the compose-file, to differentiate settings between development and production.

When everything was in one file, docker-compose would use the network definition. Now, with the override in place, docker ignore the networks, creates its own and warns me of unused networks.

My docker-compose.yml:

version: '2'

services:
  inexgw:
    ports:
      - "45308:45308"
    expose:
      - "45309"
    networks:
      - gcm
    depends_on:
      - spagw
  spagw:
    networks:
      - gcm
    environment:
      - LOGDIR=/logs
      - DBDIR=/db
    volumes:
      - ${LOGDIR}:/logs
      - ${DBDIR}:/db


networks:
  gcm:

My docker-compose.override.yml:

version: '2'

services:
  inexgw:
    restart: always
    build:
      context: ./gcm_inex/
      dockerfile: docker/Dockerfile
    environment:
      - GRAYLOGSRV=10.10.10.3
      - LOGDIR=/logs
      - LOGLEVEL=INFO
    volumes:
      - ${LOGDIR}:/logs
  spagw:
    restart: always
    build: 
      context: ./django/
      dockerfile: docker/Dockerfile
    ports:
      - "45230:45230"
    environment:
      - GRAYLOGSRV=10.10.10.3
      - LOGDIR=/logs
      - DBDIR=/db
      - LOGLEVEL=INFO

The output docker gives me:

WARNING: Some networks were defined but are not used by any service: gcm
Creating network "spagcm_default" with the default driver
Creating spagcm_spagw_1
Creating spagcm_inexgw_1

If anyone can shine a light on this behaviour I'd be obliged…

Best Answer

Found out that this has been resolved in somewhere between 1.6.0 and 1.6.2.

Just upgrade to latest docker-compose and the problem should disappear: https://docs.docker.com/compose/install/