Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compose-file network documentation seems to be wrong #3238

Closed
Hendrik-H opened this issue Mar 30, 2016 · 3 comments
Closed

compose-file network documentation seems to be wrong #3238

Hendrik-H opened this issue Mar 30, 2016 · 3 comments

Comments

@Hendrik-H
Copy link

On https://docs.docker.com/compose/compose-file/#networks networks are specified as:

networks:
  - some-network
  - other-network

Using docker-compose version 1.6.2, build 4d72027 and a version 2 file I get this error:

ERROR: In file './docker-compose.yml', network must be a mapping, not an array.

The correct syntax seems to be:

networks:
  some-network:
  other-network:
@aanand
Copy link

aanand commented Mar 30, 2016

It's confusing, but there are two different networks keys:

  • networks at the top-level of the Compose file. This must always be a mapping.
  • networks inside a service definition. This can be a mapping or an array.

Here's an example:

version: "2"

services:
  web:
    build: .
    networks:
      - foo

networks:
  foo:

@Hendrik-H
Copy link
Author

yeah, looks like you are right. thanks anyway.

@havok4u
Copy link

havok4u commented Jan 6, 2017

Thanks Hendrik-H you solved my issue. They really should document that better. I had multiple networks defined with an IP address and it kept giving me the error.

Original definition
networks:
- rcon01:
ipv4_address: 172.40.1.2
- rnet50
Gave:
ERROR: The Compose file './docker-compose.yaml' is invalid because:
services.r3.networks contains {"rcon01": {"ipv4_address": "172.40.1.2"}}, which is an invalid type, it should be a string

New definition works:

networks:
rcon01:
ipv4_address: 172.40.1.2
rnet50:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants