2
respostas

Erro networks docker-compose

Depois de ja ter configurado o docker-compose.yml deu esse erro e ainda n achei a resposta

docker-compose build ERROR: The Compose file './docker-compose.yml' is invalid because:Additional properties are not allowed ('network' was unexpected)

You might be seeing this error because you're using the wrong Compose file version. Either specify a version of "2" (or " 2.0") and place your service definitions under the services key, or omit the version key and place your service defin itions at the root of the file to use version 1. For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

Segue arquivo abaixo (docker-compose.yml)

version: '2.0'
services: 
  nginx: 
    build:
      dockerfile: ./docker/nginx.dockerfile
      context: . 
    image: douglasq/nginx
    container_name: nginx
    ports:
      - "80:80"
    networks:
      - production-network
    depends_on:
      - "node1"
      - "node2"
      - "node3"

  mongodb:
    image: mongo
    networks:
      - production-network

  node1:
    build:
      dockerfile: ./docker/alura-books.dockerfile
      context: .
    image: douglasq/alura-books
    container_name: alura-books-1
    ports:
      - "3000"
    networks: 
      - production-network
    depends_on:
      - "mongodb"

  node2:
    build:
      dockerfile: ./docker/alura-books.dockerfile
      context: .
    image: douglasq/alura-books
    container_name: alura-books-2
    ports:
      - "3000"
    networks: 
      - production-network
    depends_on:
      - "mongodb"

  node3:
    build:
      dockerfile: ./docker/alura-books.dockerfile
      context: .
    image: douglasq/alura-books
    container_name: alura-books-3
    ports:
      - "3000"
    networks: 
      - production-network
    depends_on:
      - "mongodb"

network:
  production-network:
    driver: bridge
2 respostas

docker-compose build

ERROR: The Compose file './docker-compose.yml' is invalid because: Additional properties are not allowed ('network' was unexpected)

You might be seeing this error because you're using the wrong Compose file version. Either specify a version of "2" (or " 2.0") and place your service definitions under the services key, or omit the version key and place your service defin itions at the root of the file to use version 1. For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

Kalil, ele tá reclamando da versão do arquivo composer, tenta usar uma versão mais recente, troca seu version: '2.0', por version: '3'. Ou mesmo tirar o 0 do 2.