相关疑难解决方法(0)

在Docker容器中安装node_modules并将它们与host同步

我有在node_modulesDocker容器内安装并与主机同步的问题.我的Docker的版本是18.03.1-ce, build 9ee9f40和Docker Compose的版本一样1.21.2, build a133471.

docker-compose.yml看起来像:

# Frontend Container.
frontend:
  build: ./app/frontend
  volumes:
    - ./app/frontend:/usr/src/app
    - frontend-node-modules:/usr/src/app/node_modules
  ports:
    - 3000:3000
  environment:
    NODE_ENV: ${ENV}
  command: npm start

# Define all the external volumes.
volumes:
  frontend-node-modules: ~
Run Code Online (Sandbox Code Playgroud)

我的Dockerfile:

# Set the base image.
FROM node:10

# Create and define the working directory.
RUN mkdir /usr/src/app
WORKDIR /usr/src/app

# Install the application's dependencies.
COPY package.json ./
COPY package-lock.json ./
RUN npm install …
Run Code Online (Sandbox Code Playgroud)

npm node-modules docker docker-compose

34
推荐指数
5
解决办法
2万
查看次数

标签 统计

docker ×1

docker-compose ×1

node-modules ×1

npm ×1