重建 docker 图像失败,尽管使用与集线器中所示相同的 Dockerfile
Rebuilding docker image is failing although using the same Dockerfile as shown in the hub
我想自己构建这个 docker 图像:chrisgeorge/nightmare-headless (https://hub.docker.com/r/chrisgeorge/nightmare-headless/~/dockerfile/)
所以我使用了相同的 Dockerfile。
Dockerfile
FROM node:slim
RUN apt-get update && \
apt-get install -y \
xvfb \
x11-xkb-utils \
xfonts-100dpi \
xfonts-75dpi \
xfonts-scalable \
xfonts-cyrillic \
x11-apps \
clang \
libdbus-1-dev \
libgtk2.0-dev \
libnotify-dev \
libgnome-keyring-dev \
libgconf2-dev \
libasound2-dev \
libcap-dev \
libcups2-dev \
libxtst-dev \
libxss1 \
libnss3-dev \
gcc-multilib \
g++-multilib \
xauth \
git \
sudo \
--no-install-recommends \
&& apt-get autoclean \
&& apt-get clean \
&& rm -rf /var/lib/api/lists/*
RUN chown -R node:node /home/node
RUN echo %sudo ALL=NOPASSWD: ALL >> /etc/sudoers
WORKDIR /home/node
ENV HOME /home/node
USER node
RUN npm install nightmare
npm install nightmare
将调用 npm install electron
而这是失败的:
/usr/local/lib/node_modules/electron/install.js:47
throw err
^
Error: ENOENT: no such file or directory, lstat '/usr/local/lib/node_modules/electron/dist/resources'
at Error (native)
npm ERR! Linux 4.4.0-72-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "electron"
npm ERR! node v6.10.2
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! electron@1.6.6 postinstall: `node install.js`
npm ERR! Exit status 1
更新:现在应该修复了 - https://github.com/electron/electron/issues/9323#issuecomment-298287399
这是 Electron 依赖中的一个错误,有一个 workaround:
add "extract-zip": "=1.6.0", to your project's package.json dependencies in the same place where electron dependency located.
一般来说,发生这种情况是因为dockerfile中没有指定依赖项的版本。
如果应用程序的依赖项与开发时的版本不同,则应用程序可能会中断。最佳做法是在 dockerfile 中设置大多数依赖项的版本,以便 apt install
实际上始终安装相同的软件。存在一些例外情况,例如用于健康检查的 curl 在更新后也将几乎 100% 工作
我想自己构建这个 docker 图像:chrisgeorge/nightmare-headless (https://hub.docker.com/r/chrisgeorge/nightmare-headless/~/dockerfile/)
所以我使用了相同的 Dockerfile。
Dockerfile
FROM node:slim
RUN apt-get update && \
apt-get install -y \
xvfb \
x11-xkb-utils \
xfonts-100dpi \
xfonts-75dpi \
xfonts-scalable \
xfonts-cyrillic \
x11-apps \
clang \
libdbus-1-dev \
libgtk2.0-dev \
libnotify-dev \
libgnome-keyring-dev \
libgconf2-dev \
libasound2-dev \
libcap-dev \
libcups2-dev \
libxtst-dev \
libxss1 \
libnss3-dev \
gcc-multilib \
g++-multilib \
xauth \
git \
sudo \
--no-install-recommends \
&& apt-get autoclean \
&& apt-get clean \
&& rm -rf /var/lib/api/lists/*
RUN chown -R node:node /home/node
RUN echo %sudo ALL=NOPASSWD: ALL >> /etc/sudoers
WORKDIR /home/node
ENV HOME /home/node
USER node
RUN npm install nightmare
npm install nightmare
将调用 npm install electron
而这是失败的:
/usr/local/lib/node_modules/electron/install.js:47
throw err
^
Error: ENOENT: no such file or directory, lstat '/usr/local/lib/node_modules/electron/dist/resources'
at Error (native)
npm ERR! Linux 4.4.0-72-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "electron"
npm ERR! node v6.10.2
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! electron@1.6.6 postinstall: `node install.js`
npm ERR! Exit status 1
更新:现在应该修复了 - https://github.com/electron/electron/issues/9323#issuecomment-298287399
这是 Electron 依赖中的一个错误,有一个 workaround:
add "extract-zip": "=1.6.0", to your project's package.json dependencies in the same place where electron dependency located.
一般来说,发生这种情况是因为dockerfile中没有指定依赖项的版本。
如果应用程序的依赖项与开发时的版本不同,则应用程序可能会中断。最佳做法是在 dockerfile 中设置大多数依赖项的版本,以便 apt install
实际上始终安装相同的软件。存在一些例外情况,例如用于健康检查的 curl 在更新后也将几乎 100% 工作