我试图在Docker容器中使用chrome运行一些业力测试。我的Dockerfile看起来像:
FROM node:6-alpine
RUN apk update \
&& apk add --update alpine-sdk \
&& apk add chromium \
&& npm install -g @angular/cli@1.0.0 \
&& ng set --global packageManager=yarn \
&& apk del alpine-sdk \
&& rm -rf /tmp/* /var/cache/apk/* *.tar.gz ~/.npm \
&& npm cache clear \
&& sed -i -e "s/bin\/ash/bin\/sh/" /etc/passwd
ENV CHROME_BIN=/usr/local/bin/my-chrome-build
当我在这个容器中运行ng test
时(我已经安装了一个我认识合适的项目),我得到了:
$ ng test -sr && yarn run test:server
04 04 2017 10:32:27.896:INFO [karma]: Karma v1.5.0 server started at http://0.0.0.0:9876/
04 04 2017 10:32:27.915:INFO [launcher]: Launching browser Chrome with unlimited concurrency
04 04 2017 10:32:27.985:INFO [launcher]: Starting browser Chrome
04 04 2017 10:33:28.047:WARN [launcher]: Chrome have not captured in 60000 ms, killing.
04 04 2017 10:33:30.053:WARN [launcher]: Chrome was not killed in 2000 ms, sending SIGKILL.
04 04 2017 10:33:32.056:WARN [launcher]: Chrome was not killed by SIGKILL in 2000 ms, continuing.
error Command failed with exit code 1.
我真的不知道如何调试这个,任何想法可能出错或如何找到更多?
答案 0 :(得分:1)
我在具有以下Karma浏览器配置(摘录)的Docker容器中使用Chrome无头不稳定:
...
browsers: ['Chrome_in_Docker'],
customLaunchers: {
Chrome_in_Docker: {
base: 'ChromeHeadless',
flags: [
'--disable-web-security',
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--remote-debugging-port=9223',
'--headless',
'--disable-gpu'
]
}
},
...