JaNith RathNayaka
JaNith RathNayaka

Reputation: 163

services.db.ports must be a list

my docker-compose.yaml file like this

 version: '3.9'
 services:
 backend:
 build: .
 ports:
  - 8000:3000
volumes:
  - .:/app
depends_on:
  - db

db:
image: mysql:5.7.22
restart: always
environment:
  MYSQL_DATABASE: ambassador
  MYSQL_USER: root
  MYSQL_PASSWORD: root
  MYSQL_ROOT_PASSWORD: root
volumes:
  - .db-data:/var/lib/mysql
ports: -33066:3306  

I compile use docker-compose up

I got an error like this

services.db.ports must be a list

what I can do for this error msg. anyone can help me.

Upvotes: 8

Views: 23082

Answers (1)

D-Shih
D-Shih

Reputation: 46239

Because yaml is very strict about the format.

Your port needs to be a newline(which represent be an array in yaml), use a space between the port number and port

version: '3.9'
services:
  backend:
    build: .
    ports:
      - 8000:3000
    volumes:
      - .:/app
    depends_on:
      - db
  db:
    image: mysql:5.7.22
    restart: always
    environment:
      MYSQL_DATABASE: ambassador
      MYSQL_USER: root
      MYSQL_PASSWORD: root
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - .db-data:/var/lib/mysql
    ports: 
      - 33066:3306  

Upvotes: 12

Related Questions