dockerdocker-composebindmount

docker compose -f docker-compose,yaml up fail: service volume services.database.volumes.[0] is missing a mount target


Here is my docker-compose file:

version: '2.27.0'
services:
  backend:
    container_name: nodejs
    build:
      context: /backend
      dockerfile: Dockerfile
    ports:
      -3000:3000
    restart: always

  
  database:
    container_name: mysql
    image: mysql:8.0.37
    command: mysqld --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=conbo2chan
      - MYSQL_DATABASE=TMDT
    ports:
      - '3306:3306'
    volumes: 
      - db: /var/lib/mysql
  volumes:
    db:
      driver: local


  nginx:
    container_name: nginx
    image: nginx:1.25.5-alpine
    restart: always
    ports:
      - 8080:80
    volumes:
      - /frontend: /usr/share/nginx/html

it get error: service volume services.database.volumes.[0] is missing a mount target i have mount my frontend folder ( which is contain some static file like html,css,js,image ) to the /usr/share/nginx/html but did not work. Can anyone help me pls


Solution

  • Try this :

                - db:/var/lib/mysql
               -  /frontend:/usr/share/nginx/html
    

    No space between db and /var/lib/mysql, and please check /frontend or ./frontend