【发布时间】:2019-10-01 15:40:06
【问题描述】:
我有一个 Docker 容器,我已经为一个依赖于无头 chrome 的节点应用程序使用了很长一段时间。这个容器一直工作到现在,没有改变任何东西。
容器构建正常,但是chromium在容器内启动时出错:
Error relocating /usr/lib/chromium/chrome: _ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev: symbol not found
Error relocating /usr/lib/chromium/chrome: _ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1Ev: symbol not found
Error relocating /usr/lib/chromium/chrome: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2ERKS4_mRKS3_: symbol not found
Error relocating /usr/lib/chromium/chrome: _ZNSt19_Sp_make_shared_tag5_S_eqERKSt9type_info: symbol not found
这是我的 Dockerfile:
FROM keymetrics/pm2:latest-alpine
# Install git
RUN apk --no-cache upgrade
RUN apk --no-cache add git
# Install chromium
RUN apk -U --no-cache \
--allow-untrusted add \
zlib-dev \
chromium \
xvfb \
wait4ports \
xorg-server \
dbus \
ttf-freefont \
grep \
udev \
&& apk del --purge --force linux-headers binutils-gold gnupg zlib-dev libc-utils \
&& rm -rf /var/lib/apt/lists/* \
/var/cache/apk/* \
/usr/share/man \
/tmp/* \
/usr/lib/node_modules/npm/man \
/usr/lib/node_modules/npm/doc \
/usr/lib/node_modules/npm/html \
/usr/lib/node_modules/npm/scripts
ENV CHROME_BIN=/usr/bin/chromium-browser
ENV CHROME_PATH=/usr/lib/chromium/
# Bundle app files
ADD ./dtms-api-service /server/dtms-api-service
ADD ./dtr-omnicache /server/dtr-omnicache
ADD ./dtr-webservice /server/dtr-webservice
ADD ./env.json /env.json
ADD ./env-dev.json /env-dev.json
ADD ./ecosystem.config.js /ecosystem.config.js
# Install app dependencies
ENV NPM_CONFIG_LOGLEVEL warn
RUN cd /server/dtms-api-service && npm install
RUN cd /server/dtr-omnicache && npm install
RUN cd /server/dtr-webservice && npm install
EXPOSE 3001
ENV PM2_PUBLIC_KEY <secret>
ENV PM2_SECRET_KEY <secret>
CMD ["sh", "-c", "chromium-browser --headless --disable-gpu --no-sandbox --disable-software-rasterizer --remote-debugging-port=9222 & pm2-runtime start ecosystem.config.js --env production"]
我也尝试使用它来安装 chrome,但结果相同:
# Install chromium
RUN echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && \
echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories && \
apk add --no-cache \
chromium@edge \
nss@edge
还有:
# Install chromium
RUN echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories \
&& echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories \
&& apk add --no-cache \
chromium@edge \
harfbuzz@edge \
nss@edge \
freetype@edge \
ttf-freefont@edge \
&& rm -rf /var/cache/* \
&& mkdir /var/cache/apk
编辑:事实证明,Chromium 于 9 月 25 日在 APK 存储库中进行了更新,这与它停止工作的时间一致。所以现在我必须弄清楚如何让它再次工作或切换到旧版本。
我尝试使用以下方法安装以前的版本:
RUN echo @v3.10 http://nl.alpinelinux.org/alpine/v3.10/main >> /etc/apk/repositories \
&& echo @v3.10 http://nl.alpinelinux.org/alpine/v3.10/main >> /etc/apk/repositories \
&& apk add --no-cache \
chromium@v3.10 \
harfbuzz@v3.10 \
nss@v3.10 \
freetype@v3.10 \
ttf-freefont@v3.10 \
&& rm -rf /var/cache/* \
&& mkdir /var/cache/apk
现在运行chromium-browser 命令时出现分段错误。
【问题讨论】:
标签: docker google-chrome-headless