
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
https://img.shields.io/github/stars/zenika/alpine-chrome](https://github.com/Zenika/alpine-chrome/) https://img.shields.io/github/workflow/status/zenika/alpine-chrome/build.svg](https://hub.docker.com/r/zenika/alpine-chrome/) https://img.shields.io/docker/pulls/zenika/alpine-chrome.svg](https://hub.docker.com/r/zenika/alpine-chrome/) https://img.shields.io/docker/stars/zenika/alpine-chrome.svg](https://hub.docker.com/r/zenika/alpine-chrome/)
https://img.shields.io/badge/all_contributors-39-orange.svg?style=flat-square](#-contributors)
Following the changes with the https://www.docker.com/increase-rate-limits. Tweet here for more information in 🇫🇷
zenika/alpine-chromegcr.io/zenika-hub/alpine-chromeeu.gcr.io/zenika-hub/alpine-chromeasia.gcr.io/zenika-hub/alpine-chromeus.gcr.io/zenika-hub/alpine-chromeDockerfile linkslatest, 100 https://github.com/Zenika/alpine-chrome/blob/master/Dockerfilewith-node, 100-with-node, 100-with-node-16 https://github.com/Zenika/alpine-chrome/blob/master/with-node/Dockerfilewith-puppeteer, 100-with-puppeteer https://github.com/Zenika/alpine-chrome/blob/master/with-puppeteer/Dockerfilewith-playwright, 100-with-playwright https://github.com/Zenika/alpine-chrome/blob/master/with-playwright/Dockerfilewith-selenoid, 100-with-selenoid https://github.com/Zenika/alpine-chrome/blob/master/with-selenoid/Dockerfilewith-chromedriver, 100-with-chromedriver https://github.com/Zenika/alpine-chrome/blob/master/with-chromedriver/Dockerfile89, 86, 85, 84, 83, 81, 80, 77, 76, 73, 72, 71, 68, 6489-with-node, 86-with-node, 85-with-node, 84-with-node, 83-with-node, 81-with-node, 80-with-node, 77-with-node, 76-with-node89-with-puppeteer, 86-with-puppeteer, 85-with-puppeteer,84-with-puppeteer, 83-with-puppeteer, 81-with-puppeteer, 80-with-puppeteer, 77-with-puppeteer, 76-with-puppeteerChrome running in headless mode in a tiny Alpine image
In the world of webdev, the ability to run quickly end-to-end tests are important. Popular technologies like Puppeteer enable developers to make fun things like testing, automating forms, crawling, generating screenshots, capturing timeline... And there is a secret: some of these features are directly available on Chrome! 🙌
Launching the container using only docker container run -it zenika/alpine-chrome ... will fail with some logs similar to https://github.com/Zenika/alpine-chrome/issues/33.
Please use the 3 others ways to use Chrome Headless.
--no-sandboxLaunch the container using:
docker container run -it --rm zenika/alpine-chrome and use the --no-sandbox flag for all your commands.
Be careful to know the website you're calling.
Explanation for the no-sandbox flag in a https://www.google.com/googlebooks/chrome/med_26.html and for https://chromium.googlesource.com/chromium/src/+/master/docs/design/sandbox.md
SYS_ADMIN capabilityLaunch the container using:
docker container run -it --rm --cap-add=SYS_ADMIN zenika/alpine-chrome
This allows to run Chrome with sandboxing but needs unnecessary privileges from a Docker point of view.
seccompThanks to ever-awesome Jessie Frazelle seccomp profile for Chrome. This is The most secure way to run this Headless Chrome docker image.
https://github.com/Zenika/alpine-chrome/blob/master/chrome.json
Also available here wget https://raw.githubusercontent.com/jfrazelle/dotfiles/master/etc/docker/seccomp/chrome.json
Launch the container using:
docker container run -it --rm --security-opt seccomp=$(pwd)/chrome.json zenika/alpine-chrome
The default entrypoint does the following command: chromium-browser --headless --disable-gpu --disable-software-rasterizer --disable-dev-shm-usage
You can get full control by overriding the entrypoint using: docker container run -it --rm --entrypoint "" zenika/alpine-chrome chromium-browser ...
Command (with no-sandbox): docker container run -d -p 9222:9222 zenika/alpine-chrome --no-sandbox --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 https://www.chromestatus.com/
Open your browser to: http://localhost:9222 and then click on the tab you want to inspect. Replace the beginning
https://chrome-devtools-frontend.appspot.com/serve_file/@.../inspector.html?ws=localhost:9222/[END]
by
chrome-devtools://devtools/bundled/inspector.html?ws=localhost:9222/[END]
Command (with no-sandbox): docker container run -it --rm zenika/alpine-chrome --no-sandbox --dump-dom https://www.chromestatus.com/
Command (with no-sandbox): docker container run -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome --no-sandbox --print-to-pdf --hide-scrollbars https://www.chromestatus.com/
Command (with no-sandbox): docker container run -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome --no-sandbox --screenshot --hide-scrollbars https://www.chromestatus.com/
Command (with no-sandbox): docker container run -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome --no-sandbox --screenshot --hide-scrollbars --window-size=1280,1696 https://www.chromestatus.com/
Command (with no-sandbox): docker container run -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome --no-sandbox --screenshot --hide-scrollbars --window-size=412,732 https://www.chromestatus.com/
Command (with no-sandbox): docker container run -u `id -u $USER` -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome --no-sandbox --screenshot --hide-scrollbars --window-size=412,732 [***]
Go the deno src folder. Build your image using this command:
docker image build -t zenika/alpine-chrome:with-deno-sample .
Then launch the container:
docker container run -it --rm zenika/alpine-chrome:with-deno-sample Download https://deno.land/std/examples/welcome.ts Warning Implicitly using master branch https://deno.land/std/examples/welcome.ts Compile https://deno.land/std/examples/welcome.ts Welcome to Deno 🦕
With your own file, use this command:
docker container run -it --rm -v $(pwd):/usr/src/app zenika/alpine-chrome:with-deno-sample run helloworld.ts Compile file:///usr/src/app/helloworld.ts Download https://deno.land/std/fmt/colors.ts Warning Implicitly using master branch https://deno.land/std/fmt/colors.ts Hello world!
With tool like https://pptr.dev/#?product=Puppeteer&version=v1.15.0&show=api-class-browser, we can add a lot things with our Chrome Headless.
With some code in NodeJS, we can improve and make some tests.
See the https://github.com/Zenika/alpine-chrome/blob/master/with-puppeteer folder for more details. We have to https://github.com/puppeteer/puppeteer/blob/main/versions.js.
If you have a NodeJS/Puppeteer script in your src folder named pdf.js, you can launch it using the following command:
docker container run -it --rm -v $(pwd)/src:/usr/src/app/src --cap-add=SYS_ADMIN zenika/alpine-chrome:with-puppeteer node src/pdf.js
With the https://pkgs.alpinelinux.org/package/edge/testing/x86/wqy-zenhei library, you could also manipulate asian pages like in https://github.com/Zenika/alpine-chrome/blob/master/with-puppeteer/src/screenshot-asia.js
docker container run -it --rm -v $(pwd)/src:/usr/src/app/src --cap-add=SYS_ADMIN zenika/alpine-chrome:with-puppeteer node src/screenshot-asia.js
These websites are tested with the following supported languages:
https://m.baidu.com)https://www.yahoo.co.jp/)https://www.naver.com/)https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#working-with-chrome-extensions you can not test a Chrome Extension in headleass mode. You need a display available, that's where Xvfb comes in.
See the https://github.com/Zenika/alpine-chrome/blob/master/with-puppeteer-xvfb folder for more details. We have to https://github.com/puppeteer/puppeteer/blob/main/versions.js.
Assuming you have a NodeJS/Puppeteer script in your src folder named extension.js, and the unpacked extension in the chrome-extension folder, you can launch it using the following command:
docker container run -it --rm -v $(pwd)/src:/usr/src/app/src --cap-add=SYS_ADMIN zenika/alpine-chrome:with-puppeteer-xvfb node src/extension.js
The extension provided will change the page background in red for every website visited. This demo will load the extension and take a screenshot of the icanhazip.com website.
Like https://pptr.dev/#?product=Puppeteer&version=v6.0.0&show=api-class-browser, we can do a lot things using https://playwright.dev/docs/core-concepts/#browser with our Chrome Headless.
Go to the with-playwright folder and launch the following command:
docker container run -it --rm -v $(pwd)/src:/usr/src/app/src --cap-add=SYS_ADMIN zenika/alpine-chrome:with-playwright node src/useragent.js
A example-chromium.png file will be created in your with-playwright/src folder.
By default, this image works with WebGL.
If you want to disable it, make sure to add --disable-gpu when launching Chromium.
The with-webgl tag still exists but is deprecated. It will be removed before end of August 2020.
docker container run -it --rm --cap-add=SYS_ADMIN -v $(pwd):/usr/src/app zenika/alpine-chrome --screenshot --hide-scrollbars https://webglfundamentals.org/webgl/webgl-fundamentals.html
docker container run -it --rm --cap-add=SYS_ADMIN -v $(pwd):/usr/src/app zenika/alpine-chrome --screenshot --hide-scrollbars https://browserleaks.com/webgl
Links:
https://chromedriver.chromium.org/home is a separate executable that Selenium WebDriver uses to control Chrome. You can use this image as a base for your Docker based selenium tests. See https://www.browserstack.com/guide/run-selenium-tests-using-selenium-chromedriver.
https://github.com/aerokube/selenoid is a powerful implementation of Selenium hub using Docker containers to launch browsers.
Even if it used to run browsers in docker containers, it can be quite useful as lightweight Selenium replacement.
with-selenoid image is a self sufficient selenium server, chrome and chromedriver installed.
You can run it with following command:
docker container run -it --rm --cap-add=SYS_ADMIN -p 4444:4444 zenika/alpine-chrome:with-selenoid -capture-driver-logs
And run your tests against http://localhost:4444/wd/hub
One of the use-cases might be running automation tests in the environment with restricted Docker environment
like on some CI systems like GitLab CI, etc. In such case you may not have permissions for --cap-add=SYS_ADMIN
and you will need to pass the --no-sandbox to chromedriver.
See more selenoid docs
We can run the container as root with this command:
docker container run --rm -it --entrypoint "" --user root zenika/alpine-chrome sh
Some examples are available on the examples directory:
Headless Chrome website: https://developers.google.com/web/updates/2017/04/headless-chrome
List of all options of the "Chromium" command line: [***]
Where to file issues: https://github.com/Zenika/alpine-chrome/issues
Maintained by: [***]
docker container run -it --rm --entrypoint "" zenika/alpine-chrome cat /etc/alpine-release 3.15.4
docker container run -it --rm --entrypoint "" zenika/alpine-chrome chromium-browser --version Chromium 100.0.4896.60
docker image inspect zenika/alpine-chrome --format='{{.Size}}' 357467827 # 341 MB
Thanks goes to these wonderful people (emoji key):
Julien Landuré https://github.com/Zenika/alpine-chrome/commits?author=jlandure https://github.com/Zenika/alpine-chrome/pulls?q=is%3Apr+reviewed-by%3Ajlandure https://github.com/Zenika/alpine-chrome/commits?author=jlandure 🤔 💬 🚧 | https://github.com/lygstate https://github.com/Zenika/alpine-chrome/commits?author=lygstate 🤔 💬 | Dennis Koch https://github.com/Zenika/alpine-chrome/commits?author=pxlrbt 🤔 💬 | https://github.com/sargonpiraev https://github.com/Zenika/alpine-chrome/commits?author=sargonpiraev | https://github.com/ebriand https://github.com/Zenika/alpine-chrome/commits?author=ebriand | https://github.com/huhai463127310 https://github.com/Zenika/alpine-chrome/commits?author=huhai463127310 🤔 | Roman Pushkin https://github.com/Zenika/alpine-chrome/commits?author=ro31337 |
Juan Lladó https://github.com/Zenika/alpine-chrome/commits?author=jllado | https://github.com/c24w https://github.com/Zenika/alpine-chrome/issues?q=author%3Ac24w | Wang Guan https://github.com/Zenika/alpine-chrome/issues?q=author%3Ajokester | https://github.com/OscarSotoSanchez https://github.com/Zenika/alpine-chrome/issues?q=author%3AOscarSotoSanchez | Calinoiu Alexandru Nicolae https://github.com/Zenika/alpine-chrome/issues?q=author%3Aalexandru-calinoiu | https://github.com/mamacdon https://github.com/Zenika/alpine-chrome/issues?q=author%3Amamacdon | Felix Mann https://github.com/Zenika/alpine-chrome/issues?q=author%3ADJFliX |
| https://github.com/horacimacias https://github.com/Zenika/alpine-chrome/issues?q=author%3Ahoracimacias | Emil Kjer https://github.com/Zenika/alpine-chrome/issues?q=author%3Aemilkjer | https://github.com/likwid https://github.com/Zenika/alpine-chrome/issues?q=author%3Alikwid | George Gaál https://github.com/Zenika/alpine-chrome/issues?q=author%3Agecube | https://github.com/wheestermans31 https://github.com/Zenika/alpine-chrome/issues?q=author%3Awheestermans31 | https://github.com/hodossy https://github.com/Zenika/alpine-chrome/issues?q=author%3Ahodossy | https://github.com/ardeois https://github.com/Zenika/alpine-chrome/issues?q=author%3Aardeois |
Danny Althoff 💬 | https://github.com/chadlwilson 💬 🤔 | https://github.com/fenchu https://github.com/Zenika/alpine-chrome/issues?q=author%3Afenchu | https://github.com/nrawat*** https://github.com/Zenika/alpine-chrome/issues?q=author%3Anrawat*** | x0rzkov https://github.com/Zenika/alpine-chrome/issues?q=author%3Ax0rzkov 🤔 | https://github.com/jketterl |
以下是 zenika/alpine-chrome 相关的常用 Docker 镜像,适用于 不同场景 等不同场景:
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务