⚠️ Note: This guide has been integrated into the Comprehensive Docker Guide. This document is kept as a quick reference for Alpine Linux-specific information. For complete Docker documentation covering all operating systems, see the Comprehensive Docker Guide.
This guide helps you use GuardScan in Docker containers, especially Alpine Linux environments.
# Install dependencies first
apk add --no-cache python3 make g++ pkgconfig cairo-dev pango-dev \
libjpeg-turbo-dev giflib-dev pixman-dev freetype-dev build-base git
# Install GuardScan
npm install -g guardscan
# Initialize
guardscan initSymptoms:
Configuration not found. Run "guardscan init" first.
Cause: Alpine Linux containers may have issues with home directory detection.
Solutions:
-
Set GUARDSCAN_HOME environment variable:
export GUARDSCAN_HOME=/tmp/guardscan guardscan init -
Ensure HOME is set:
export HOME=/root # or appropriate directory guardscan init
-
Enable debug mode to see what's happening:
export GUARDSCAN_DEBUG=true guardscan init
Cause: Container may have restricted write permissions.
Solution: Use /tmp or a writeable volume:
export GUARDSCAN_HOME=/tmp/guardscan
# or mount a volume
docker run -v /path/on/host:/guardscan node:lts-alpine
export GUARDSCAN_HOME=/guardscanCause: Alpine uses musl instead of glibc and needs additional build tools.
Solution: Install all required dependencies:
apk add --no-cache \
python3 \
make \
g++ \
pkgconfig \
cairo-dev \
pango-dev \
libjpeg-turbo-dev \
giflib-dev \
pixman-dev \
freetype-dev \
build-base \
gitOverride the default home directory location.
export GUARDSCAN_HOME=/custom/pathDefault behavior:
- Tries
$GUARDSCAN_HOMEfirst - Falls back to
$HOME - Falls back to
$USERPROFILE(Windows) - Falls back to
os.homedir() - Last resort:
/tmp
Enable verbose debug logging to troubleshoot issues.
export GUARDSCAN_DEBUG=true
guardscan init # Will show detailed loggingFROM node:lts-alpine
# Install dependencies
RUN apk add --no-cache \
python3 make g++ pkgconfig cairo-dev pango-dev \
libjpeg-turbo-dev giflib-dev pixman-dev freetype-dev build-base git
# Install GuardScan
RUN npm install -g guardscan
# Set up config location
ENV GUARDSCAN_HOME=/app/.guardscan
# Your code
WORKDIR /app
COPY . .
# Run GuardScan
RUN guardscan initversion: '3.8'
services:
guardscan:
image: node:lts-alpine
environment:
- GUARDSCAN_HOME=/workspace/.guardscan
- GUARDSCAN_DEBUG=false
volumes:
- ./:/workspace
working_dir: /workspace
command: sh -c "
apk add --no-cache python3 make g++ pkgconfig cairo-dev pango-dev
libjpeg-turbo-dev giflib-dev pixman-dev freetype-dev build-base git &&
npm install -g guardscan &&
guardscan scan
"name: GuardScan Security Check
on: [push, pull_request]
jobs:
security-scan:
runs-on: ubuntu-latest
container:
image: node:lts-alpine
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
apk add --no-cache python3 make g++ pkgconfig cairo-dev pango-dev \
libjpeg-turbo-dev giflib-dev pixman-dev freetype-dev build-base git
- name: Install GuardScan
run: npm install -g guardscan
- name: Run security scan
env:
GUARDSCAN_HOME: ${{ github.workspace }}/.guardscan
run: guardscan securityFor enhanced security with read-only root:
docker run --read-only --tmpfs /tmp \
-e GUARDSCAN_HOME=/tmp/guardscan \
node:lts-alpine \
sh -c "npm install -g guardscan && guardscan init"Run the test script to verify GuardScan works in your environment:
cd cli
./test-alpine.shThis will test:
- ✅ Clean Alpine environment
- ✅ Missing HOME variable
- ✅ Custom GUARDSCAN_HOME
- ✅ Read-only filesystems
- ✅ Version check behavior
- ✅ Multiple commands in sequence
If GuardScan isn't working in your container:
- Are all dependencies installed?
- Is
$HOMEor$GUARDSCAN_HOMEset? - Is the target directory writable?
- Did you run with
GUARDSCAN_DEBUG=true? - Are you using
node:lts-alpineor compatible image? - Did you run
npm install -g guardscansuccessfully?
If you're still experiencing issues:
-
Enable debug mode:
GUARDSCAN_DEBUG=true guardscan init 2>&1 | tee debug.log
-
Check home directory:
node -e "console.log(require('os').homedir())" -
Verify write permissions:
mkdir -p ~/.guardscan && echo "test" > ~/.guardscan/test.txt
-
Open an issue: GitHub Issues
- Include the debug log
- Mention your Docker image
- Include your Dockerfile if relevant