Home > Blockchain >  Running docker-compose up -d -build , I got the following error:
Running docker-compose up -d -build , I got the following error:

Time:08-27

The Compose file '.\docker-compose.yml' is invalid because: services.mysql.networks contains an invalid type, it should be an array, or an object

this is the code:

 mysql:
    image: mysql:5.7.29
    container_name: mysql
    restart: unless-stopped
    tty: true
    ports:
      - "3306:3306"
    environment:
      MYSQL_DATABASE: laravel
      MYSQL_USER: homestead
      MYSQL_PASSWORD: secret
      MYSQL_ROOT_PASSWORD: secret
      SERVICE_TAGS: dev
      SERVICE_NAME: mysql
    networks: 
      -backend

CodePudding user response:

You are missing a space when you defined the network ;) This would work if the backend network already exists in your system!

   mysql:
    image: mysql:5.7.29
    container_name: mysql
    restart: unless-stopped
    tty: true
    ports:
      - "3306:3306"
    environment:
      MYSQL_DATABASE: laravel
      MYSQL_USER: homestead
      MYSQL_PASSWORD: secret
      MYSQL_ROOT_PASSWORD: secret
      SERVICE_TAGS: dev
      SERVICE_NAME: mysql
    networks:
      - backend
  • Related