Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid type error in Docker Compose

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.

  • docker-compose version 1.8.0-rc1, build 9bf6bc6
  • docker-py version: 1.8.1
  • CPython version: 2.7.11
  • OpenSSL version: OpenSSL 1.0.2d 9 Jul 2015
like image 711
Mayank Avatar asked Jun 22 '16 06:06

Mayank


People also ask

How do I validate a docker compose file?

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.

What is the latest version of Docker compose?

docker-compose 1.20.

What is Docker compose depends?

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.


1 Answers

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" 
like image 148
Nguyen Sy Thanh Son Avatar answered Sep 21 '22 10:09

Nguyen Sy Thanh Son