Reputation: 33
My objective is to use 1 bridge network in docker for all my docker-compose on the same host, for all my domains.
I have configured 3 yml file for my docker-compose infrastructure and I'm using 1 external bridge network dockerprometheus_back-tier for all of them. One YAML file for reverse proxy (traefik) and one YAML file for each domain name (2 files).
Each time I'm trying to stop & start the last YAML with the command docker-compose -f mail.yml down && docker-compose -f mail.yml up -d
, I got :
yaml.scanner.ScannerError: mapping values are not allowed here
After commenting most of the commands in the yml 3, I understand that the problem is when I add the line name: dockerprometheus_back-tier
But in the 2 other yml files, I already did exactly the same configuration to use this network and the yaml processor doesn't complain.
YAML 1
version: '3'
networks:
internal:
external: false
prometheus:
external: true
name: dockerprometheus_back-tier
YAML 2
version: '3'
networks:
onlyinternal:
driver: bridge
external: false
prometheus:
external: true
name: dockerprometheus_back-tier
docker network ls
04e3348408c4 dockerprometheus_back-tier bridge local
I applied dos2unix to clean the encoding on the YAML 3 but doesn't change anything. I made a copy directly of the YAML 3, keeping the first lines, and trying to start it but it failed too with same error. Is there a limitation in docker to use 3 times the same bridge network from external files? How to solve it?
Docker version 18.09.3, build 774a1f4 , CentOS Linux release 7.6.1810 (Core)
YAML 3:
version: '3'
networks:
mail_network:
driver: bridge
external: false
prometheus:
external: true
name: dockerprometheus_back-tier
Upvotes: 2
Views: 3704
Reputation: 76599
All three YAML documents you present have the same problem and are all invalid.
As value for the key external
you have a multi-line unquoted scalar
true name: dockerprometheus_back-tier
within an unquoted scalar you cannot have a value indicator followed by whitespace as this might indicate a new key. Either quote the multi-line scalar:
networks:
mail_network:
driver: bridge
external: false
prometheus:
external: "true
name: dockerprometheus_back-tier"
Or if name
should be a key at the same level as external
, make sure it is indented as such:
networks:
mail_network:
driver: bridge
external: false
prometheus:
external: true
name: dockerprometheus_back-tier
You can have something like the following in YAML:
prometheus:
external:
name: dockerprometheus_back-tier
but of course a key cannot both have, as value, a scalar node (true
) and a mapping node ('name: dockerprometheus_back-tier')
Upvotes: 1