Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Erro no docker-compose build

Boa Noite, estou com problemas ao rodar o comando:

docker-compose build, estou usando o Ubuntu 20.04 lts.

Minha versão do docker-compose: 1.26.2

Minha versão do Docker: 19.03.12

Mensagem exibida

ERROR: The Compose file './docker-compose.yml' is invalid because: Invalid top-level property "network". Valid top-level sections for this Compose file are: version, services, networks, volumes, secrets, configs, and extensions starting with "x-".

You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the services key, or omit the version key and place your service definitions 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/

Meu docker-compose.yml

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

  mongodb:
    image: mongo
    networks:  
      - productions-network  

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

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

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

network:
  productions-network:
    - driver: bridge
1 resposta
solução!

Você escreveu "network" mas o correto é "networks" (plural)