1
resposta

Erro ao rodar o comando docker-compose build

version: "3"
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"
networks:
  production-network:
    driver: bridge

Ao rodar o comando docker-compose build, me aparece o seguinte erro:

ERROR: Top level object in './docker-compose.yml' needs to be an object not '<type 'str'>'.

1 resposta

Olá Larissa,

Mude:

De: version: "3"

Para: version: '3'

Ou seja, mude de aspas dupla para aspas simples. Salve o arquivo e execute novamente o comando.