Quick Start
Build the Docker image
The
--build-arg LINKSPECTOR_PACKAGE= argument installs from the current directory rather than npm.Building the Image
Build from Current Directory
Install the local version of Linkspector:Build Specific Version from npm
Install a specific version from npm:Build Latest from npm
Install the latest published version:Dockerfile Overview
The Linkspector Dockerfile includes:Why Chromium?
Linkspector uses Puppeteer with Chromium to check links in headless browser mode, which:- Reduces false positives from JavaScript-rendered sites
- Handles complex redirects and client-side routing
- Supports both ARM64 and AMD64 architectures
Running Linkspector
Basic Usage
Run with default configuration (.linkspector.yml):
Custom Configuration File
Specify a custom configuration file:JSON Output
Output results in RDJSON format:Show Statistics
Display detailed link check statistics:Volume Mounting
Mount Project Directory
The-v $PWD:/app flag mounts your current directory to /app in the container:
$PWD is a shell variable for the current directory. On Windows PowerShell, use ${PWD} instead.Mount Specific Subdirectories
Check only specific documentation directories:Mount Multiple Configuration Files
Docker Compose
Create adocker-compose.yml for repeatable link checking:
docker-compose.yml
CI/CD Integration
GitLab CI
.gitlab-ci.yml
Jenkins
Jenkinsfile
CircleCI
.circleci/config.yml
Advanced Usage
Interactive Shell
Open an interactive shell in the container:Environment Variables
Pass environment variables for authentication:.linkspector.yml:
Custom Network
Run on a custom Docker network to access other containers:Save Results to File
Redirect output to a file on the host:Troubleshooting
Permission denied errors
Permission denied errors
If you encounter permission errors, ensure the mounted volume has correct permissions:
Chromium crashes or fails to start
Chromium crashes or fails to start
The Docker image is configured to run Chromium with:
--no-sandboxfor containerized environments--headless=newfor improved performance--remote-debugging-port=0to avoid D-Bus issues
Cannot find configuration file
Cannot find configuration file
Ensure
.linkspector.yml is in the mounted directory:Network timeout errors
Network timeout errors
If external links timeout, increase Docker’s network timeout or add problematic domains to
ignorePatterns in your configuration.Container exits immediately
Container exits immediately
Add
-it flags for interactive mode and proper TTY allocation:Image Details
- Base Image:
node:lts-bookworm-slim - Included Tools: Node.js, npm, Chromium, Git, Bash
- Working Directory:
/app - Default User:
node(non-root) - Architecture Support: AMD64, ARM64
Best Practices
Use .dockerignore
Create
.dockerignore to exclude unnecessary files when building the image.Pin Image Version
Use specific version tags in production instead of
latest.Multi-stage Builds
For custom images, use multi-stage builds to minimize image size.
Health Checks
Add health checks when running Linkspector as a service.
Next Steps
CI/CD Integration
Integrate Docker-based checks into CI/CD pipelines
GitHub Actions
Use the official GitHub Action instead of Docker