Dockerfile:
FROM iron/node
RUN apk add --update bash && rm -rf /var/cache/apk/*
RUN apk add --update curl && rm -rf /var/cache/apk/*
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN npm install
CMD [ "node", "index.js" ]
docker构建日志:
Sending build context to Docker daemon 198.2 MB
Step 1 : FROM iron/node
---> 9ca501065d18
Step 2 : RUN apk add --update bash && rm -rf /var/cache/apk/*
---> Using cache
---> 0a03d023f33e
Step 3 : RUN apk add --update curl && rm -rf /var/cache/apk/*
---> Using cache
---> 3e0176dae102
Step 4 : WORKDIR /usr/src/app
---> Using cache
---> 3f9d925bd76c
Step 5 : COPY . /usr/src/app
---> 0c2c195505dd
Removing intermediate container de7cb9edede2
Step 6 : RUN npm install
---> Running in d7549ec2707d
Error relocating /usr/bin/node: uv_os_free_passwd: symbol not found
Error relocating /usr/bin/node: uv_os_get_passwd: symbol not found
The command '/bin/sh -c npm install' returned a non-zero code: 127
怎么回事?这些错误是什么意思?:
Error relocating /usr/bin/node: uv_os_free_passwd: symbol not found
Error relocating /usr/bin/node: uv_os_get_passwd: symbol not found
如何解决此问题?
不确定这是怎么回事。我显然没有你的应用程序,但我尝试了一个公共模块(例如newman(的npm安装,但我遇到了同样的错误。查看该图像的dockerhub页面,我发现了Dockerfile,它似乎卸载了npm。事实上,当我直接运行dockerfile时,没有npm——所以我不确定公众形象是如何保持的,除非他们的构建过程目前有点崩溃。
顺便说一下,这样做有点低效:
RUN apk add --update bash && rm -rf /var/cache/apk/*
RUN apk add --update curl && rm -rf /var/cache/apk/*
相反,您应该同时安装bash和curl:
RUN apk add --update bash curl && rm -rf /var/cache/apk/*
结合所有这些步骤(即直接使用dockerfile,并结合apk安装(,而不卸载npm给了我:
FROM iron/base:edge
RUN echo '@edge http://nl.alpinelinux.org/alpine/edge/main' >> /etc/apk/repositories
# RUN echo '@community http://nl.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories
RUN apk update && apk upgrade
&& apk add nodejs@edge bash curl
&& rm -rf /var/cache/apk/*
RUN npm install -g newman
这似乎很有效。