我想要构建一个 docker 镜像,但实际上我已经好几年没有这样做了,我已经忘记了关于 docker 的大部分知识。我想在上传到 GCP 之前在本地进行测试。
回复:我正在从节点:12 更新。*
无论如何,这是我的 dockerfile:
FROM node:16-alpine
RUN echo "deb http://nginx.org/packages/mainline/debian/ stretch nginx \deb-src http://nginx.org/packages/mainline/debian/ stretch nginx" > /etc/apt/sources.list.d/nginx.list && wget -qO - https://nginx.org/keys/nginx_signing.key | apt-key add -
RUN apt update -y && apt install -y nginx build-essential gyp libpng-dev bzip2 autoconf libtool nasm libvips-dev --no-install-recommends && rm -rf /var/lib/apt/lists/* && mkdir -p /usr/src/app
COPY ./package.json /usr/src/app/
WORKDIR /usr/src/app/
RUN npm install -g node-gyp
我收到了这个错误:
Step 1/6 : FROM node:16-alpine
---> 2573171e0124
Step 2/6 : RUN echo "deb http://nginx.org/packages/mainline/debian/ stretch nginx \deb-src http://nginx.org/packages/mainline/debian/ stretch nginx" > /etc/apt/sources.list.d/nginx.list && wget -qO - https://nginx.org/keys/nginx_signing.key | apt-key add -
---> Running in ff30404cf27a
/bin/sh: can't create /etc/apt/sources.list.d/nginx.list: nonexistent directory
The command '/bin/sh -c echo "deb http://nginx.org/packages/mainline/debian/ stretch nginx \deb-src http://nginx.org/packages/mainline/debian/ stretch nginx" > /etc/apt/sources.list.d/nginx.list && wget -qO - https://nginx.org/keys/nginx_signing.key | apt-key add -' returned a non-zero code: 1
现在,这说得通了,因为我没有这个目录 - 但我 3 年前更新过它,不记得遇到过它。但更重要的是 - 如果我没有直接在本地拥有它(我确实运行 nginx) - 有没有办法让它静音?我尝试创建它并遇到权限问题。