【问题标题】:How to avoid ` invalid mount path` in docker-compose如何避免 docker-compose 中的“无效挂载路径”
【发布时间】:2020-09-09 05:28:01
【问题描述】:

我有docker-compose.yml 喜欢关注

version: '3'

services:
  api-server:
    build: ./api
    links:
      - 'db'
    ports:
      - '3000:3000'
    volumes:
      - ./api:/src
      - ./src/node_modules
    tty: true
    container_name: api-server

  db:
    build:
      context: .
      dockerfile: ./db/Dockerfile
    restart: always
    hostname: db
    environment:
      MYSQL_ROOT_PASSWORD: test
      MYSQL_USER: test
      MYSQL_PASSWORD: test
      MYSQL_DATABASE: test
    volumes:
      - './db:/config'
    ports:
      - 3306:3306
    container_name: db

当我尝试docker-compose up

$ docker-compose up -d

我遇到了一些错误,例如以下错误。

似乎给它们设置了绝对路径。但在此消息未出现之前。

我想知道

①是什么原因导致这个错误。

③如何在不重写绝对路径的情况下修复它。

db is up-to-date
Recreating bf6187ceff2f_api-server ... error
ERROR: for bf6187ceff2f_api-server  Cannot create container for service api-server: invalid volume specification: '9131f8ce856163b2935bd8f09d5e6a2e67509fd5adee9b2d1903cd760639beaa:src/node_modules:rw': invalid mount config for type "volume": invalid mount path: 'src/node_modules' mount path must be absolute
ERROR: for api-server  Cannot create container for service api-server: invalid volume specification: '9131f8ce856163b2935bd8f09d5e6a2e67509fd5adee9b2d1903cd760639beaa:src/node_modules:rw': invalid mount config for type "volume": invalid mount path: 'src/node_modules' mount path must be absolute

ERROR: Encountered errors while bringing up the project.

如果有人有意见,请告诉我。

谢谢

【问题讨论】:

    标签: javascript node.js docker express docker-compose


    【解决方案1】:

    刚刚看到你正在尝试做this。

    您所描述的错误正在发生,因为您需要指定容器内的绝对路径,因此它安装在一个卷上。就像是 这个:/src/node_modules

    【讨论】:

      猜你喜欢
      • 2017-05-17
      • 1970-01-01
      • 2019-10-25
      • 2020-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-19
      • 1970-01-01
      相关资源
      最近更新 更多