I am facing error in Docker Compose. The compose file is
version: '2' services: api: build: context: . dockerfile: webapi/dockerfile ports: - 210 web: build: context: . dockerfile: app/dockerfile ports: - 80 lbapi: image: dockercloud/haproxy links: – api ports: – 8080:210 lbweb: image: dockercloud/haproxy links: – web ports: – 80:80
The error when running docker-compose up
is:
ERROR: The Compose file '.\docker-compose.yml' is invalid because: services.lbapi.ports contains an invalid type, it should be an array services.lbweb.ports contains an invalid type, it should be an array services.lbapi.links contains an invalid type, it should be an array services.lbweb.links contains an invalid type, it should be an array
Please help.
Validating your file now is as simple as docker-compose -f docker-compose. yml config . As always, you can omit the -f docker-compose. yml part when running this in the same folder as the file itself or having the COMPOSE_FILE environment variable pointing to your file.
docker-compose 1.20.
2. Docker Compose depends_on. depends_on is a Docker Compose keyword to set the order in which services must start and stop. For example, suppose we want our web application, which we'll build as a web-app image, to start after our Postgres container.
Did you try with quotes on ports?
version: '2' services: api: build: context: . dockerfile: webapi/dockerfile ports: - 210 web: build: context: . dockerfile: app/dockerfile ports: - 80 lbapi: image: dockercloud/haproxy links: – api ports: – "8080:210" lbweb: image: dockercloud/haproxy links: – web ports: – "80:80"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With