支持基于 Debian 12 (bookworm-slim) 构建的 Chrome/chromium/firefox + VNC + noVNC 容器,支持通过浏览器或 VNC 客户端访问 浏览器 图形界面。
Chrome只支持x86_64架构
firefox支持x86_64/arm64架构
chromium只支持arm64架构(因kylin v10 arm64无法运行基于Debian 12构建的chromium,单独dockerfile构建基于kylin v10 SP2 arm64构建的90.0.4430.212版本chromium镜像,但因版本过低,会有部分网页无法正常显示)
本镜像适用于需要在容器中运行 Chrome 浏览器,并通过 Web 端或 VNC 远程访问的场景。支持中文字体、Emoji 显示,并可选安装 XFCE 桌面环境。
docker run -it --rm -p 6080:6080 -p 5901:5901 liyuleii/chrome-vnc:amd64-2025-8-15
访问方式(默认密码a123456) 1、noVNC Web: 浏览器访问 http://:6080 输入密码即可进入 Chrome。
| 变量名 | 默认值 | 说明 |
|---|---|---|
PORT | 6080 | noVNC Web 服务端口 |
PASSWORD | a123456 | Web 端和 VNC 连接密码 |
SSL_ENABLE | false | 是否启用 SSL(true/false) |
SCREEN_WIDTH | 1366 | 虚拟屏幕宽度 |
SCREEN_HEIGHT | 768 | 虚拟屏幕高度 |
SCREEN_DEPTH | 24 | 屏幕色深 |
START_URL | file:///index.html | Chrome 启动时加载的 URL |
LANG | en_US.UTF-8 | 系统语言 |
LC_ALL | en_US.UTF-8 | 系统区域设置 |
services:
chrome:
container_name: chrome
image: liyuleii/chrome-vnc:amd64-2025-8-15
restart: always
cpus: 2
mem_limit: 2048M
network_mode: host
ports:
- "6080:6080" # noVNC Web 端口
- "5901:5901" # VNC 客户端端口
environment:
- PASSWORD=a123456
- LANGUAGE=zh_CN.UTF-8 # 程序中文语言
- LANG=zh_CN.UTF-8 # 系统中文语言
- LC_ALL=zh_CN.UTF-8 # 强制中文语言
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:6080"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# 使用方法(kylin-v10-arm64 chromium无法运行,需要安装firefox)
## 第一阶段:下载依赖包
# docker build --target downloader -t browser-deb-vnc ./
## 第二阶段:构建镜像
# docker build -t dcim/browser-vnc:amd64-chrome141.0.7390.122-2025-10-29 ./
FROM debian:bookworm-slim AS downloader
# 是否安装桌面环境安装true,不安装false
ARG INSTALL_XFCE="false"
# 选择浏览器:chrome | firefox
ARG BROWSER="chrome"
# 更新包索引并安装必要工具,同时定义要安装的软件包并下载
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates curl wget gnupg; \
arch="$(uname -m)"; \
if [ "$BROWSER" = "chrome" ] && [ "$arch" = "x86_64" ]; then \
curl -fsSL https://dl.google.com/linux/linux_signing_key.pub \
| gpg --dearmor -o /usr/share/keyrings/google-linux-signing-keyring.gpg; \
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-linux-signing-keyring.gpg] https://dl.google.com/linux/chrome/deb/ stable main" \
> /etc/apt/sources.list.d/google-chrome.list; \
fi; \
apt-get update; \
# 定义要安装的软件包 \
PKGS="locales fontconfig supervisor tigervnc-standalone-server tightvncserver novnc websockify procps fonts-wqy-microhei fonts-noto-color-emoji"; \
if [ "$INSTALL_XFCE" = "true" ]; then \
PKGS="$PKGS xfce4 dbus-x11 xterm"; \
fi; \
if [ "$BROWSER" = "chrome" ] && [ "$arch" = "x86_64" ]; then \
PKGS="$PKGS google-chrome-stable"; \
elif [ "$BROWSER" = "chrome" ] && [ "$arch" = "aarch64" ]; then \
PKGS="$PKGS chromium chromium-l10n"; \
else \
PKGS="$PKGS firefox-esr firefox-esr-l10n-zh-cn"; \
fi; \
echo "将安装的包: $PKGS"; \
apt-get install -y --no-install-recommends --download-only $PKGS; \
mkdir -p /deb-cache; \
cp -a /var/cache/apt/archives/*.deb /deb-cache/; \
# 保存APT索引、源配置和密钥
mkdir -p /apt-lists /apt-sources /apt-keyrings; \
cp -a /var/lib/apt/lists /apt-lists/; \
cp -a /etc/apt/sources.list* /apt-sources/; \
cp -a /usr/share/keyrings/* /apt-keyrings/ 2>/dev/null || true
# 第二阶段:使用依赖包安装并设置
FROM debian:bookworm-slim
# 默认环境变量
ENV PORT=6080 \
PASSWORD=a123456 \
LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
SCREEN_WIDTH=1366 \
SCREEN_HEIGHT=768 \
SCREEN_DEPTH=24 \
START_URL=file:///index.html
# 拷贝deb包和APT索引、源配置及密钥
COPY --from=downloader /deb-cache /tmp/debs
COPY --from=downloader /apt-lists/lists /var/lib/apt/lists
COPY --from=downloader /apt-sources/ /etc/apt/
COPY --from=downloader /apt-keyrings/ /usr/share/keyrings/
# 安装软件包并清理无用文件
RUN set -eux; \
apt-get install -y --no-install-recommends /tmp/debs/*.deb; \
echo "zh_CN.UTF-8 UTF-8" > /etc/locale.gen; \
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \
locale-gen; \
fc-cache -f -v; \
# 清理临时文件和缓存以减小镜像大小
rm -rf /tmp/debs /var/lib/apt/lists/* /root/.cache /var/cache/apt/archives/*; \
# 移除文档文件以进一步减小镜像大小
find /usr/share/doc -mindepth 1 -delete; \
find /usr/share/man -mindepth 1 -delete; \
find /usr/share/info -mindepth 1 -delete; \
# 清理字体缓存
rm -rf /var/cache/fontconfig/*
# 创建首页文件:///index.html
RUN printf '%s\n' \
'<!doctype html>' \
'<html lang="en">' \
'<meta charset="utf-8" />' \
'<meta name="viewport" content="width=device-width, initial-scale=1" />' \
'<title>VNC browser</title>' \
'<body style="font-family: system-ui, -apple-system, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, Arial, \"Noto Color Emoji\", \"Noto Sans CJK\", sans-serif; line-height: 1.6; padding: 24px;">' \
' <h1>VNC browser</h1>' \
' <p>Container is running. Connect via noVNC on port 6080.</p>' \
'</body>' \
'</html>' > /index.html && \
# 重命名vnc首页文件
cp /usr/share/novnc/vnc.html /usr/share/novnc/index.html 2>/dev/null || true
# 启动脚本
COPY startup.sh /startup.sh
RUN chmod +x /startup.sh
COPY ./Dockerfile /
VOLUME ["/config"]
EXPOSE 6080/tcp 5901/tcp
CMD ["/startup.sh"]
# 使用方法(kylin v10 arm64架构chromium浏览器)
# docker build -t dcim/chrome-vnc:arm64-90.0.4430.212-2025-10-27 ./
## 原镜像地址:kylinv10/kylin:b09
FROM liyuleii/kylin-v10:sp2-arm64
# Environment defaults
ENV PORT=6080 \
PASSWORD=a123456 \
LANG=zh_CN.UTF-8 \
LC_ALL=zh_CN.UTF-8 \
SCREEN_WIDTH=1366 \
SCREEN_HEIGHT=768 \
SCREEN_DEPTH=24 \
START_URL=file:///index.html
# 配置麒麟国防版源
RUN cat > /etc/yum.repos.d/kylin-cs2c.repo <<'EOF'
[kylin-v10-base]
name=Extra Packages for cs2c kylin v10 base - $basearch
baseurl=https://update.cs2c.com.cn/NS/V10/V10-GFB/030/os/adv/lic/base/$basearch/
enabled=1
gpgcheck=0
[kylin-v10-updates]
name=Extra Packages for cs2c kylin v10 updates - $basearch
baseurl=https://update.cs2c.com.cn/NS/V10/V10-GFB/030/os/adv/lic/updates/$basearch/
enabled=1
gpgcheck=0
EOF
# dnf安装必要依赖
RUN dnf install -y \
glibc-langpack-zh \
fontconfig \
tigervnc-server \
procps-ng \
wqy-microhei-fonts \
google-noto-emoji-color-fonts \
chromium \
wget \
python3
# pip安装必要依赖
RUN pip3 install \
supervisor \
websockify \
novnc
# 下载vnc首页文件(官方地址https://github.com/novnc/noVNC/archive/refs/tags/v1.6.0.zip)和创建chromium首页文件并清理缓存文件
RUN printf '%s\n' \
'<!doctype html>' \
'<html lang="en">' \
'<meta charset="utf-8" />' \
'<meta name="viewport" content="width=device-width, initial-scale=1" />' \
'<title>VNC Chrome</title>' \
'<body style="font-family: system-ui, -apple-system, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, Arial, \"Noto Color Emoji\", \"Noto Sans CJK\", sans-serif; line-height: 1.6; padding: 24px;">' \
' <h1>VNC Chrome</h1>' \
' <p>Container is running. Connect via noVNC on port 6080.</p>' \
'</body>' \
'</html>' > /index.html && \
# 下载 noVNC index.html
curl -L -o /usr/share/noVNC-1.6.0.zip https://lf1.liyulei.eu.org:89/data/pkg/chrome-image-build/noVNC-1.6.0.zip && \
unzip /usr/share/noVNC-1.6.0.zip -d /usr/share/ && \
mv /usr/share/noVNC-1.6.0/ /usr/share/novnc/ && \
cp /usr/share/novnc/vnc.html /usr/share/novnc/index.html && \
mkdir /etc/supervisor/ && \
ln -s /usr/local/bin/websockify /usr/bin/websockify && \
ln -s /usr/bin/chromium-browser /usr/bin/chromium && \
ln -s /usr/local/bin/supervisord /usr/bin/supervisord && \
dnf clean all && \
rm -rf /usr/share/noVNC-1.6.0.zip && \
rm -rf /var/cache/dnf/* && \
rm -rf /var/tmp/* && \
rm -rf /root/.cache
# Supervisor and startup
COPY startup.sh /startup.sh
RUN chmod +x /startup.sh
COPY ./Dockerfile /
VOLUME ["/config"]
EXPOSE 6080/tcp 5901/tcp
CMD ["/startup.sh"]
#!/bin/bash
set -e
# ====================== env defaults ======================
NOVNC_PORT="${PORT:-6080}"
NOVNC_PASSWORD="${PASSWORD:-a123456}"
SSL_ENABLE="${SSL_ENABLE:-false}"
SSL_CERT_PATH="${SSL_CERT_PATH:-/certs/fullchain.pem}"
SSL_KEY_PATH="${SSL_KEY_PATH:-/certs/privkey.pem}"
SCREEN_WIDTH="${SCREEN_WIDTH:-1366}"
SCREEN_HEIGHT="${SCREEN_HEIGHT:-768}"
SCREEN_DEPTH="${SCREEN_DEPTH:-24}"
START_URL="${START_URL:-file:///index.html}"
echo "正在启动 supervisord..."
echo "将使用屏幕分辨率: ${SCREEN_WIDTH}x${SCREEN_HEIGHT}x${SCREEN_DEPTH}"
echo "默认首页: $START_URL"
# 创建 VNC 密码
mkdir -p /root/.vnc
echo -n "$NOVNC_PASSWORD" | vncpasswd -f > /root/.vnc/passwd
chmod 600 /root/.vnc/passwd
# ====================== 智能检测浏览器可执行文件 ======================
CHROME_CMD=""
# 1. 优先检测 google-chrome-stable (x86_64 官方版)
if [ -x "/usr/bin/google-chrome-stable" ]; then
CHROME_CMD="/usr/bin/google-chrome-stable"
echo "检测到浏览器: google-chrome-stable"
# 2. 其次检测 chromium (arm64 降级或备用)
elif [ -x "/usr/bin/chromium" ]; then
CHROME_CMD="/usr/bin/chromium"
echo "检测到浏览器: chromium"
# 3. 最后检测 firefox 或 firefox-esr(任一存在即可)
elif [ -x "/usr/bin/firefox" ]; then
CHROME_CMD="/usr/bin/firefox"
echo "检测到浏览器: firefox"
elif [ -x "/usr/bin/firefox-esr" ]; then
CHROME_CMD="/usr/bin/firefox-esr"
echo "检测到浏览器: firefox-esr"
# 4. 兜底失败
else
echo "错误: 找不到浏览器可执行文件!"
exit 1
fi
echo "将使用浏览器: $CHROME_CMD"
# 生成supervisord配置-全局配置
cat > /etc/supervisor/supervisord.conf <<EOF
[supervisord]
nodaemon=true
user=root
logfile=/dev/stdout
logfile_maxbytes=0
loglevel=warn
EOF
# 生成supervisord配置-vnc启动配置
cat >> /etc/supervisor/supervisord.conf <<EOF
[program:xvnc]
command=/usr/bin/Xvnc :1 -rfbauth /root/.vnc/passwd -geometry ${SCREEN_WIDTH}x${SCREEN_HEIGHT} -depth ${SCREEN_DEPTH} -SecurityTypes=VncAuth -localhost=0
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
redirect_stderr=true
EOF
if [ "$SSL_ENABLE" = "true" ] && [ -f "$SSL_CERT_PATH" ] && [ -f "$SSL_KEY_PATH" ]; then
# 生成supervisord配置-novnc https启动配置
cat >> /etc/supervisor/supervisord.conf <<EOF
[program:novnc]
command=/usr/bin/websockify --web /usr/share/novnc/ --cert=$SSL_CERT_PATH --key=$SSL_KEY_PATH --ssl-only $NOVNC_PORT localhost:5901
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
redirect_stderr=true
EOF
else
# 生成supervisord配置-novnc http启动配置
cat >> /etc/supervisor/supervisord.conf <<EOF
[program:novnc]
command=/usr/bin/websockify --web /usr/share/novnc/ $NOVNC_PORT localhost:5901
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
redirect_stderr=true
EOF
fi
# 生成supervisord配置-xfce启动配置
if [ -x "/usr/bin/startxfce4" ]; then
echo "检测到XFCE,正在添加XFCE桌面环境..."
cat >> /etc/supervisor/supervisord.conf <<EOF
[program:xfce4]
command=/usr/bin/startxfce4
environment=DISPLAY=":1",XDG_CURRENT_DESKTOP="XFCE",XAUTHORITY="/root/.Xauthority"
autorestart=true
priority=10
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
redirect_stderr=true
EOF
fi
# ====================== 动态生成浏览器启动命令 ======================
# 根据检测到的浏览器,生成不同启动参数
if [[ "$CHROME_CMD" == *firefox* ]]; then
# Firefox 专用参数
BROWSER_ARGS="--no-remote --profile /config --width ${SCREEN_WIDTH} --height ${SCREEN_HEIGHT} --display=:1"
FULL_COMMAND="$CHROME_CMD $BROWSER_ARGS ${START_URL}"
echo "使用 Firefox 启动参数"
else
# Chrome / Chromium 专用参数(保留你原有全部优化)
BROWSER_ARGS="--no-sandbox --disable-infobars --disable-crash-reporter --disable-fre --no-first-run --disable-default-apps --no-default-browser-check --disable-gpu --restore-last-session --remote-debugging-port=9222 --user-data-dir=/config --disable-dev-shm-usage --display=:1 --window-size=${SCREEN_WIDTH},${SCREEN_HEIGHT} --disable-logging --log-level=3 --disable-setuid-sandbox --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-component-extensions-with-background-pages --disable-extensions --disable-features=TranslateUI --disable-hang-monitor --disable-ipc-flooding-protection --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --password-store=basic --use-mock-keychain"
FULL_COMMAND="$CHROME_CMD $BROWSER_ARGS ${START_URL}"
echo "使用 Chrome/Chromium 启动参数"
fi
# 生成supervisord配置-浏览器启动配置(使用 bash -c 避免参数解析问题)
cat >> /etc/supervisor/supervisord.conf <<EOF
[program:browser]
command=bash -c "$FULL_COMMAND"
environment=HOME="/config",XDG_CONFIG_HOME="/config/.config",XDG_DATA_HOME="/config/.local/share",XDG_RUNTIME_DIR="/config/runtime_dir"
autorestart=true
priority=20
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
redirect_stderr=true
EOF
# ====================== 启动 supervisord ======================
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
Content type
Image
Digest
sha256:ed1830a97…
Size
612.4 MB
Last updated
12 months ago
docker pull liyuleii/chrome-vnc:arm64-chromium140.0.7339.185-2025-9-28