简体   繁体   中英

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.

This is the 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:

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

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. 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
# echo $?
1

Besides, there is no such thing as /var/app/node_modules mounted in the container:

# 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
  2. I am not sure what the command apk del .gyp is doing, but you may need to investigate it. It does not seems to work properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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