Bug: Cannot set up chromium user profile through novnc because `DISPLAY` does not exist on `docker compose run --rm archivebox``
Provide a screenshot and describe the bug
I was trying to do https://github.com/ArchiveBox/ArchiveBox/wiki/Chromium-Install#setting-up-a-chromium-user-profile I edited docker-compose.yml:
services:
archivebox:
image: ${ARCHIVEBOX_IMAGE:-archivebox/archivebox:dev}
restart: unless-stopped
ports:
- "${ARCHIVEBOX_PORT:-8000}:8000"
volumes:
- ./data:/data
# Override abx-dl's nested VOLUME so profiles persist across containers.
- ./data/personas:/data/personas
# Let one-off `docker compose run` commands reuse the server's supervisor.
- tmp:/tmp/archivebox
pids_limit: 2048 # avoids low systemd task caps with Chrome and parallel extractors
environment:
- DISPLAY=novnc:0.0
shm_size: "1gb" # Chrome runs more efficiently when using a reasonably sized shared memory pool
novnc:
image: theasp/novnc:latest
profiles:
- novnc
environment:
- DISPLAY_WIDTH=1920
- DISPLAY_HEIGHT=1080
- RUN_XTERM=no
ports:
- 127.0.0.1:8080:8080
volumes:
tmp:and ran
docker compose up -d novnc docker compose run --rm archivebox persona create personal
then the next command showed errors (by the way my chromium was /opt/archivebox/lib/playwright/cache/chromium-1234/chrome-linux64/chrome, not /data/lib/env/bin/chromium as written in the doc)
~/archivebox$ docker compose run --rm archivebox /opt/archivebox/lib/playwright/cache/chromium-1234/chrome-linux64/chrome --user-data-dir=/data/personas/personal/chrome_profile --profile-directory=Default --disable-gpu --disable-features=dbus --disable-dev-shm-usage --start-maximized --no-sandbox --disable-setuid-sandbox --no-zygote --disable-sync --no-first-run
Container archivebox-archivebox-run-6797c295fd3b Creating
Container archivebox-archivebox-run-6797c295fd3b Created
[7:7:0904/170637.920022:ERROR:ui/ozone/platform/x11/ozone_platform_x11.cc:257] Missing X server or $DISPLAY
[7:420:0904/170637.918421:ERROR:dbus/bus.cc:405] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[7:7:0904/170637.925310:ERROR:ui/aura/env.cc:246] The platform failed to initialize. Exiting.This is because the environment variable DISPLAY does not exist while docker compose run --rm archivebox
~/archivebox$ docker compose run --rm archivebox sh -c '
if [ -z "${DISPLAY+x}" ]; then
echo "DISPLAY is not set"
else
echo "DISPLAY is set to: $DISPLAY"
fi
'
Container archivebox-archivebox-run-2e4397da9cb6 Creating
Container archivebox-archivebox-run-2e4397da9cb6 Created
DISPLAY is not setThere is a workaround for this issue:
DISPLAY does exist after docker compose up -d archivebox --wait so just run chromium after that: e.g.
docker compose up -d archivebox --wait
docker exec -it <container_id> bash
/opt/archivebox/lib/playwright/cache/chromium-1234/chrome-linux64/chrome --user-data-dir=/data/personas/personal/chrome_profile --profile-directory=Default --disable-gpu --disable-features=dbus --disable-dev-shm-usage --start-maximized --no-sandbox --disable-setuid-sandbox --no-zygote --disable-sync --no-first-runClaude suggested https://github.com/ArchiveBox/ArchiveBox/blob/dev/bin/docker_entrypoint.sh#L178 as the cause:
# check if novnc x11 $DISPLAY is available
export DISPLAY="${DISPLAY:-"novnc:0.0"}"
if ! xdpyinfo > /dev/null 2>&1; then
# cant connect to x11 display, unset it so that chrome doesn't try to connect to it and hang indefinitely
unset DISPLAY
fiTo see what happened here I ran below command:
~/archivebox$ docker compose run --rm archivebox sh -c 'xdpyinfo -display novnc:0.0'
Container archivebox-archivebox-run-c502753a3521 Creating
Container archivebox-archivebox-run-c502753a3521 Created
sh: 1: xdpyinfo: not foundSteps to reproduce
wrote aboveLogs or errors
ArchiveBox Version
0.9.35rc381 (Docker compose on WSL2)How did you install the version of ArchiveBox you are using?
Docker (or Podman/LXC/K8s/TrueNAS/Proxmox/etc)
What operating system are you running on?
Windows (including WSL, WSL2, Docker Desktop on Windows)
What type of drive are you using to store your ArchiveBox data?
- some of
data/is on a local SSD or NVMe drive - some of
data/is on a spinning hard drive or external USB drive - some of
data/is on a network mount (e.g. NFS/SMB/Ceph/GlusterFS/etc.) - some of
data/is on a FUSE mount (e.g. SSHFS/RClone/S3/B2/Google Drive/Dropbox/etc.)
Docker Compose Configuration
ArchiveBox Configuration
Source: ArchiveBox/ArchiveBox