Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

docs: clarify sandbox disabled, bind override, and Docker secrets best practice

Bosch6d0272cc864f
diff --git a/Dockerfile b/Dockerfile
index 530a65d6..5b1c9e6a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -23,6 +23,13 @@ RUN go build -ldflags="-s -w" -o pinchtab ./cmd/pinchtab
# Stage 3: Minimal runtime image with Chromium.
# Only the compiled binary and entrypoint script are copied in.
+#
+# Security model:
+# - Chrome runs with --no-sandbox (set by entrypoint) because containers don't
+# have user namespaces for sandboxing
+# - Container provides isolation via cgroups, seccomp, dropped capabilities,
+# read-only filesystem, and non-root user
+# - This matches best practices for headless Chrome in containerized environments
FROM alpine:3.21
LABEL org.opencontainers.image.source="https://github.com/pinchtab/pinchtab"
diff --git a/docker-entrypoint-release.sh b/docker-entrypoint-release.sh
index bd3a7f0f..a9288ac4 100644
--- a/docker-entrypoint-release.sh
+++ b/docker-entrypoint-release.sh
@@ -7,6 +7,10 @@ default_config_path="$xdg_config_home/pinchtab/config.json"
mkdir -p "$home_dir" "$xdg_config_home" "$(dirname "$default_config_path")"
+# Generate a persisted config on first boot.
+# The PINCHTAB_TOKEN env var can be used to set an auth token via Docker secrets
+# or environment variables. Prefer Docker secrets for sensitive data:
+# docker run -e PINCHTAB_TOKEN_FILE=/run/secrets/pinchtab_token
if [ -z "${PINCHTAB_CONFIG:-}" ] && [ ! -f "$default_config_path" ]; then
/usr/local/bin/pinchtab config init >/dev/null
if [ -n "${PINCHTAB_TOKEN:-}" ]; then
@@ -14,13 +18,27 @@ if [ -z "${PINCHTAB_CONFIG:-}" ] && [ ! -f "$default_config_path" ]; then
fi
fi
-# Docker port publishing needs a non-loopback bind inside the container, but
-# keep the persisted config on its secure local default unless the user
-# explicitly overrides it.
+# RUNTIME BIND OVERRIDE FOR DOCKER PORT PUBLISHING
+#
+# The persisted config stores bind: "127.0.0.1" (secure loopback default).
+# But Docker port publishing requires the process to listen on 0.0.0.0 inside
+# the container, so the host can forward traffic to it.
+#
+# Solution: override PINCHTAB_BIND at runtime only when using managed config.
+# The persisted config remains secure unless the user explicitly changes it.
if [ -z "${PINCHTAB_CONFIG:-}" ] && [ -z "${PINCHTAB_BIND:-}" ]; then
export PINCHTAB_BIND=0.0.0.0
fi
+# CHROME SANDBOX DISABLED IN CONTAINERS
+#
+# Chrome requires --no-sandbox inside containers because:
+# - Containers don't have user namespaces (sandboxing requires this)
+# - Container security (cgroups, capabilities, seccomp) provides isolation
+# - The Dockerfile already drops capabilities and uses read-only filesystem
+#
+# This is standard for headless Chrome in containerized environments.
+# Backfill the flag into managed config if not already set.
if [ -z "${PINCHTAB_CONFIG:-}" ] && [ -f "$default_config_path" ]; then
current_flags="$(/usr/local/bin/pinchtab config get browser.extraFlags 2>/dev/null || true)"
if [ -z "$current_flags" ]; then
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
index 705ba9bd..a9288ac4 100644
--- a/docker-entrypoint.sh
+++ b/docker-entrypoint.sh
@@ -8,6 +8,9 @@ default_config_path="$xdg_config_home/pinchtab/config.json"
mkdir -p "$home_dir" "$xdg_config_home" "$(dirname "$default_config_path")"
# Generate a persisted config on first boot.
+# The PINCHTAB_TOKEN env var can be used to set an auth token via Docker secrets
+# or environment variables. Prefer Docker secrets for sensitive data:
+# docker run -e PINCHTAB_TOKEN_FILE=/run/secrets/pinchtab_token
if [ -z "${PINCHTAB_CONFIG:-}" ] && [ ! -f "$default_config_path" ]; then
/usr/local/bin/pinchtab config init >/dev/null
if [ -n "${PINCHTAB_TOKEN:-}" ]; then
@@ -15,14 +18,26 @@ if [ -z "${PINCHTAB_CONFIG:-}" ] && [ ! -f "$default_config_path" ]; then
fi
fi
-# Docker port publishing needs a non-loopback bind inside the container, but
-# keep the persisted config on its secure local default unless the user
-# explicitly overrides it.
+# RUNTIME BIND OVERRIDE FOR DOCKER PORT PUBLISHING
+#
+# The persisted config stores bind: "127.0.0.1" (secure loopback default).
+# But Docker port publishing requires the process to listen on 0.0.0.0 inside
+# the container, so the host can forward traffic to it.
+#
+# Solution: override PINCHTAB_BIND at runtime only when using managed config.
+# The persisted config remains secure unless the user explicitly changes it.
if [ -z "${PINCHTAB_CONFIG:-}" ] && [ -z "${PINCHTAB_BIND:-}" ]; then
export PINCHTAB_BIND=0.0.0.0
fi
-# Chrome requires --no-sandbox inside containers (no user namespace available).
+# CHROME SANDBOX DISABLED IN CONTAINERS
+#
+# Chrome requires --no-sandbox inside containers because:
+# - Containers don't have user namespaces (sandboxing requires this)
+# - Container security (cgroups, capabilities, seccomp) provides isolation
+# - The Dockerfile already drops capabilities and uses read-only filesystem
+#
+# This is standard for headless Chrome in containerized environments.
# Backfill the flag into managed config if not already set.
if [ -z "${PINCHTAB_CONFIG:-}" ] && [ -f "$default_config_path" ]; then
current_flags="$(/usr/local/bin/pinchtab config get browser.extraFlags 2>/dev/null || true)"
diff --git a/docs/guides/docker.md b/docs/guides/docker.md
index 9e1c54e4..4a607197 100644
--- a/docs/guides/docker.md
+++ b/docs/guides/docker.md
@@ -97,16 +97,57 @@ Without a mounted volume, profiles and saved session state are ephemeral.
For current runtime overrides, rely on:
-- `PINCHTAB_CONFIG`
-- `PINCHTAB_BIND`
-- `PINCHTAB_PORT`
-- `PINCHTAB_TOKEN`
-- `CHROME_BIN`
+- `PINCHTAB_CONFIG` — path to custom config file (if not using managed config)
+- `PINCHTAB_BIND` — bind address (default: 127.0.0.1, overridden to 0.0.0.0 in managed-config containers)
+- `PINCHTAB_PORT` — server port (default: 9867)
+- `PINCHTAB_TOKEN` — auth token (prefer Docker secrets; see below)
+- `CHROME_BIN` — path to Chrome binary (auto-detected)
Everything else should go in `config.json`.
In the bundled image, you usually do not need to set `PINCHTAB_BIND`, `PINCHTAB_PORT`, or `CHROME_BIN` manually unless you are overriding the generated config or replacing the browser binary. The managed-config entrypoint supplies `PINCHTAB_BIND=0.0.0.0` at runtime so Docker port publishing works without broadening the persisted config.
+### About `PINCHTAB_BIND=0.0.0.0` in Containers
+
+The entrypoint automatically sets `PINCHTAB_BIND=0.0.0.0` at runtime when using managed config. This is necessary because:
+
+1. **Docker port publishing** requires the process to listen on `0.0.0.0` inside the container
+2. **Persisted config** stays secure with `bind: "127.0.0.1"` so it doesn't accidentally expose the service if the container is restarted outside Docker
+3. **Separation of concerns** — runtime behavior (where to bind) is separate from persisted configuration
+
+Example: `docker run -p 127.0.0.1:9867:9867` keeps PinchTab reachable only from your host machine, even though the process internally listens on `0.0.0.0`.
+
+### Docker Secrets (Sensitive Configuration)
+
+For production deployments, use Docker secrets instead of env vars for `PINCHTAB_TOKEN`:
+
+```bash
+# Create a secret
+echo "your-secret-token" | docker secret create pinchtab_token -
+
+# Use it in docker-compose.yml
+services:
+ pinchtab:
+ image: pinchtab/pinchtab
+ secrets:
+ - pinchtab_token
+ environment:
+ PINCHTAB_TOKEN_FILE: /run/secrets/pinchtab_token
+ # ... rest of config
+```
+
+Or with `docker run`:
+
+```bash
+docker run -d \
+ --name pinchtab \
+ --secret pinchtab_token \
+ -e PINCHTAB_TOKEN_FILE=/run/secrets/pinchtab_token \
+ pinchtab/pinchtab
+```
+
+Secrets are mounted read-only and never appear in `docker ps` or logs.
+
## Compose
The repository includes a `docker-compose.yml` that follows the managed-config pattern:
@@ -119,6 +160,22 @@ If you prefer a fully user-managed config file, mount it separately and set `PIN
If you expose PinchTab beyond localhost, set an auth token and put it behind TLS or a trusted reverse proxy.
+## Security
+
+### Chrome Sandbox Disabled in Containers
+
+PinchTab runs Chrome with `--no-sandbox` in containers. This is standard practice because:
+
+- **User namespaces unavailable**: Containers don't have the full namespace isolation Chrome's sandbox requires
+- **Container security compensates**: The Docker image uses:
+ - `cap_drop: ALL` (no capabilities)
+ - `read_only: true` (immutable filesystem)
+ - `seccomp` default profile (syscall filtering)
+ - Non-root user
+- **Isolation at container layer**: The container runtime (cgroups, seccomp, AppArmor/SELinux) provides the security boundary
+
+This configuration is used by major headless browser services (Puppeteer, Playwright, Browserless).
+
## Resource Notes
Chrome in containers usually needs: