Skip to content

Instantly share code, notes, and snippets.

@image72
Last active October 30, 2025 10:53
Show Gist options
  • Select an option

  • Save image72/329986ea5ebabc5515849f1b19db2686 to your computer and use it in GitHub Desktop.

Select an option

Save image72/329986ea5ebabc5515849f1b19db2686 to your computer and use it in GitHub Desktop.
Alpine Chrome Docker with auto-start - Self-contained Dockerfile with heredocs (no external files needed)

Alpine Chrome Selkies Docker

A lightweight Alpine-based Chrome browser container using the Selkies base image with auto-start functionality.

Quick Start

For AMD64/x86_64 servers:

docker run -d \
  --name=alpine-chrome \
  -e PUID=1000 \
  -e PGID=1000 \
  -e TZ=Etc/UTC \
  -e PASSWORD="yourpassword" \
  -p 3000:3000 \
  -p 3001:3001 \
  -v ./chrome-config:/config \
  
  --restart unless-stopped \
  image72/alpine-chrome-selkies:amd64

Docker Compose (Recommended):

---
services:
  alpine-chrome:
    image: image72/alpine-chrome-selkies:amd64
    container_name: alpine-chrome
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - PASSWORD=yourpassword
      - CHROME_CLI=https://www.linuxserver.io/ #optional
    volumes:
      - /path/to/config:/config
    ports:
      - 3000:3000
      - 3001:3001
    shm_size: "1gb"
    restart: unless-stopped

Build from Source

The Dockerfile is now self-contained with all files embedded using heredocs:

# Download the self-contained Dockerfile
curl -O https://gist.githubusercontent.com/image72/329986ea5ebabc5515849f1b19db2686/raw/alpine-chrome.Dockerfile

# Build for your platform (no external files needed!)
docker build -f alpine-chrome.Dockerfile -t alpine-chrome .

# Run
docker run -d -p 3000:3000 -e PASSWORD="yourpassword" alpine-chrome

Features

  • Auto-start Chrome: Chromium browser launches automatically on container start
  • XFCE Desktop: Full desktop environment with file manager, terminal, etc.
  • Web Access: Access via browser at http://your-server:3000 (HTTP) or https://your-server:3001 (HTTPS)
  • HTTPS Support: Self-signed certificate included for secure access
  • Alpine Base: Smaller image size compared to Ubuntu/Debian variants
  • Password Protection: Set PASSWORD environment variable for security
  • Persistent Config: Mount /config volume to persist settings and data

Included Packages

  • chromium - Main browser
  • xfce4 - Desktop environment
  • thunar - File manager
  • xfce4-terminal - Terminal emulator
  • mousepad - Text editor
  • ristretto - Image viewer
  • Plus various GTK themes and utilities

Environment Variables

Variable Description Default
PUID User ID for file permissions 1000
PGID Group ID for file permissions 1000
TZ Timezone (e.g., America/New_York) Etc/UTC
PASSWORD Web interface password (recommended) abc
CUSTOM_USER HTTP Basic auth username abc
CHROME_CLI Additional Chrome command line arguments -

Ports

Port Protocol Description
3000 HTTP Web interface (HTTP)
3001 HTTPS Web interface (HTTPS) - Recommended

Volumes

Path Description
/config User home directory - stores settings, bookmarks, downloads

Important Notes

HTTPS Access

  • HTTPS is required for full functionality - Modern browser features like WebCodecs (video/audio) require secure connections
  • Access via: https://your-server:3001
  • Uses self-signed certificate by default (you'll see a security warning - click "Advanced" → "Proceed")

Security Warning

  • Container provides privileged access to host system
  • Do not expose to internet without proper security measures
  • For internet access, use behind reverse proxy like SWAG

Troubleshooting

Platform Issues

If you get platform mismatch warnings, explicitly specify the platform:

docker run --platform linux/amd64 ...

Performance

For better performance on servers, consider:

  • Allocating more memory: --memory=2g
  • Required SHM size: --shm-size=1gb (needed for modern websites like YouTube)

Reverse Proxy Setup

If using behind a reverse proxy that validates certificates, you may need to disable certificate validation for this container.

# syntax=docker/dockerfile:1
FROM ghcr.io/linuxserver/baseimage-selkies:alpine322
# set version label
ARG BUILD_DATE
ARG VERSION
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="custom"
# title
ENV TITLE=Chrome
RUN \
echo "**** add icon ****" && \
mkdir -p /usr/share/selkies/www && \
curl -o \
/usr/share/selkies/www/icon.png \
https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/chrome-logo.png && \
echo "**** install packages ****" && \
apk add --no-cache \
adw-gtk3 \
adwaita-xfce-icon-theme \
chromium \
mousepad \
ristretto \
thunar \
util-linux-misc \
xfce4 \
xfce4-terminal \
curl \
ca-certificates && \
echo "**** cleanup ****" && \
rm -rf \
/var/cache/apk/* \
/tmp/* \
/var/tmp/*
# Create autostart script using heredoc
RUN mkdir -p /defaults && cat <<EOF > /defaults/autostart
#!/bin/bash
wrapped-chrome \${CHROME_CLI}
EOF
# Create wrapped-chrome script using heredoc
RUN cat <<EOF > /usr/bin/wrapped-chrome
#!/bin/bash
BIN=/usr/bin/chromium-browser
# Cleanup
if pgrep chromium > /dev/null;then
rm -f \$HOME/.config/chromium/Singleton*
fi
\${BIN} \\
--no-first-run \\
--no-sandbox \\
--password-store=basic \\
--simulate-outdated-no-au='Tue, 31 Dec 2099 23:59:59 GMT' \\
--start-maximized \\
--test-type \\
--user-data-dir \\
--disable-dev-shm-usage \\
--disable-gpu \\
"\$@" > /dev/null 2>&1
EOF
# Create menu.xml using heredoc
RUN cat <<EOF > /defaults/menu.xml
<?xml version="1.0" encoding="utf-8"?>
<openbox_menu xmlns="http://openbox.org/3.4/menu">
<menu id="root-menu" label="MENU">
<item label="xterm" icon="/usr/share/pixmaps/xterm-color_48x48.xpm"><action name="Execute"><command>/usr/bin/xterm</command></action></item>
<item label="Chrome" icon="/usr/share/icons/hicolor/48x48/apps/chromium.png"><action name="Execute"><command>/usr/bin/wrapped-chrome</command></action></item>
</menu>
</openbox_menu>
EOF
# Make scripts executable
RUN chmod +x /defaults/autostart /usr/bin/wrapped-chrome
# ports and volumes
EXPOSE 3000
VOLUME /config
#!/bin/bash
wrapped-chrome ${CHROME_CLI}
<?xml version="1.0" encoding="utf-8"?>
<openbox_menu xmlns="http://openbox.org/3.4/menu">
<menu id="root-menu" label="MENU">
<item label="xterm" icon="/usr/share/pixmaps/xterm-color_48x48.xpm"><action name="Execute"><command>/usr/bin/xterm</command></action></item>
<item label="Chrome" icon="/usr/share/icons/hicolor/48x48/apps/chromium.png"><action name="Execute"><command>/usr/bin/wrapped-chrome</command></action></item>
</menu>
</openbox_menu>
#!/bin/bash
BIN=/usr/bin/chromium-browser
# Cleanup
if pgrep chromium > /dev/null;then
rm -f $HOME/.config/chromium/Singleton*
fi
${BIN} \
--no-first-run \
--no-sandbox \
--password-store=basic \
--simulate-outdated-no-au='Tue, 31 Dec 2099 23:59:59 GMT' \
--start-maximized \
--test-type \
--user-data-dir \
--disable-dev-shm-usage \
--disable-gpu \
"$@" > /dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment