Search code examples
dockerdocker-composedocker-network

Docker compose with networks and "internal" property example


I tried to find example of usage "internal" property with a network declaration in docker-compose.yml v2.

Other words I search how to do this:

docker network create someName --internal

but in docker-compose.yml.

I get error when try to use this variant:

version: '2'

services:
# services definition

networks:
  someName:
    internal: true

Error message:

The Compose file '.\docker-compose.yml' is invalid because:
networks.someName value Additional properties are not allowed ('internal' was unexpected)

Solution

  • Upgrade to docker-compose 1.9 or later, internal networks are a new feature of the docker-compose.yml.

    Instructions to upgrade are on the compose releases page.