Joh*_*ton 5 node.js npm docker
我正在尝试通过创建一个简单的nodejs图像来学习docker:
# Dockerfile
FROM node:10
RUN npm install -g yarn
EXPOSE 8080
WORKDIR /usr/src/app
Run Code Online (Sandbox Code Playgroud)
当我运行时docker build -t "node10" .
,出现以下错误:
> [2/3] RUN npm install -g yarn:
#5 2.007
#5 2.007 > yarn@1.22.10 preinstall /usr/local/lib/node_modules/yarn
#5 2.007 > :; (node ./preinstall.js > /dev/null 2>&1 || true)
#5 2.007
#5 2.565 npm ERR! code EEXIST
#5 2.573 npm ERR! syscall symlink
#5 2.581 npm ERR! path ../lib/node_modules/yarn/bin/yarn.js
#5 2.581 npm ERR! dest /usr/local/bin/yarn
#5 2.582 npm ERR! errno -17
#5 2.589 npm ERR! EEXIST: file already exists, symlink '../lib/node_module
s/yarn/bin/yarn.js' -> '/usr/local/bin/yarn'
#5 2.589 npm ERR! File exists: /usr/local/bin/yarn
#5 2.590 npm ERR! Remove the existing file and try again, or run npm
#5 2.591 npm ERR! with --force to overwrite files recklessly.
#5 2.598
#5 2.599 npm ERR! A complete log of this run can be found in:
#5 2.599 npm ERR! /root/.npm/_logs/2021-03-25T05_08_51_089Z-debug.log
Run Code Online (Sandbox Code Playgroud)
我该如何修复这个错误?
Dav*_*aze 10
标准 Docker Hubnode
镜像已经包含 Yarn;您不需要单独安装它。
~% docker run --rm node:10 yarn --version
1.13.0
Run Code Online (Sandbox Code Playgroud)
只是COPY
你的package.json
和yarn.lock
中的 和RUN yarn install
。删除该RUN npm install -g yarn
行,这是不必要的,您的错误是与预安装的 Yarn 冲突。
FROM node:10
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
CMD [ "npm", "run", "start" ]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8266 次 |
最近记录: |