简体   繁体   English

Dockerfile问题

[英]Dockerfile issues

Hi I got a project with a dockerfile, and I am trying to build the dockerfile to run the project in the environment it was created but I seem to get an error at step 5 of the build and when I look at the dockerfile I find the code a bit strange/I dont understand it at that point. 嗨,我有一个带有dockerfile的项目,我试图构建dockerfile在创建该项目的环境中运行该项目,但是在构建的第5步似乎出现错误,当我查看dockerfile时,我发现代码有点奇怪/我当时不明白。

This is the dockerfile: 这是dockerfile:

FROM node:8.10-alpine

ENV NODE_ENV development

# Create app directory
WORKDIR /var/app

# Install Node packages
COPY package.json package.json

RUN apk install git \

  && npm i \
  && apk del .gyp\
  && mv /var/app/node_modules /node_modules \
  && rm -rf /var/cache/apk/* \
  && apk del git

# Bundle app source
COPY . .
#COPY entrypoint.sh entrypoint.sh

# Expose port
EXPOSE 88

#ENTRYPOINT ["./entrypoint.sh"]
CMD ["npm", "run", "dev"]

This is the error i am getting: 这是我得到的错误:

Step 5/8 : RUN apk install git   && npm i   && apk del .gyp  && mv /var/app/node_modules /node_modules   && rm -rf /var/cache/apk/*   && apk del git
 ---> Running in 251259cdb8a2
apk-tools 2.7.5, compiled for x86_64.

Then I get a bunch of text which resembles what you get if you type -help on something and then at the end i get: 然后,我得到一堆类似于您在某事上输入-help时所得到的文本,最后我得到:

This apk has coffee making abilities.
The command '/bin/sh -c apk install git   && npm i   && apk del .gyp  && mv /var/app/node_modules /node_modules   && rm -rf /var/cache/apk/*   && apk del git' returned a non-zero code: 1

This seems to be the problematic part: 这似乎是有问题的部分:

RUN apk install git \
  && npm i \
  && apk del .gyp\
  && mv /var/app/node_modules /node_modules \
  && rm -rf /var/cache/apk/* \
  && apk del git

Just try adding an additional line before using apk and see if it fixes 在使用apk之前,只需尝试添加其他行,看看它是否可以解决

RUN echo "ipv6" >> /etc/modules
RUN apk install git \ 

Reference: link 参考: 链接

Note : Breaking the problematic step into multiple steps like 注意 :将有问题的步骤分为多个步骤,例如

RUN apk install git
RUN npm i 
RUN apk del .gyp
RUN mv /var/app/node_modules /node_modules 
RUN rm -rf /var/cache/apk/* 
RUN apk del git

will help to locate the point of problem more accurately. 将有助于更准确地定位问题点。

You have 2 issues. 您有2期。 One is with the command apk del .gyp (which return code is different from 0 ) , and the other is related to the fact that you do not mount correctly your folder. 一种是使用命令apk del .gyp (返回码不同于0 ),另一种是与您没有正确安装文件夹的事实有关。

# apk del .gyp
# echo $?
1

Besides, there is no such thing as /var/app/node_modules mounted in the container: 此外,容器中/var/app/node_modules安装/var/app/node_modules这样的东西:

# ls /var/app/node_modules
# ls: /var/app/node_modules: No such file or directory

What you would do, is 你会做的是

  1. Make sure you mount correctly /var/app/node_modules in the container 确保在容器中正确安装了/var/app/node_modules
  2. I am not sure what the command apk del .gyp is doing, but you may need to investigate it. 我不确定apk del .gyp命令在做什么,但是您可能需要对其进行调查。 It does not seems to work properly. 它似乎无法正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM