A Docker container for BookStack - a simple, self-hosted platform for organizing and storing information.
BookStack is an opinionated wiki system that provides a pleasant and simple out-of-the-box experience. New users to an instance should find the experience intuitive and only basic word-processing skills should be required to get involved in creating content.
- PHP 8.2 with Apache web server
- MySQL/MariaDB database support (BookStack's officially supported databases)
- All required PHP extensions for BookStack functionality
- Configurable admin credentials via environment variables
- Optimized configuration for performance and security
- Volume support for persistent data storage
- Health checks included
- Simple Docker setup
# Pull and run the pre-built image from Docker Hub
docker run -d \
--name bookstack \
-p 8080:80 \
-v bookstack_storage:/var/www/html/storage/uploads \
-v bookstack_public:/var/www/html/public/uploads \
-e BOOKSTACK_ADMIN_EMAIL=admin@example.com \
-e BOOKSTACK_ADMIN_PASSWORD=changeme123 \
-e BOOKSTACK_ADMIN_NAME=Admin \
-e TZ=UTC \
-e BOOKSTACK_APP_URL=http://localhost:8080 \
-e DB_HOST=your-db-host \
-e DB_DATABASE=bookstack \
-e DB_USERNAME=bookstack \
-e DB_PASSWORD=your-db-password \
--restart unless-stopped \
itefixnet/bookstack:latest# Build the image
docker build -t bookstack .
# Run the container (admin credentials and timezone are REQUIRED)
# You must provide database connection details
docker run -d \
--name bookstack \
-p 8080:80 \
-v bookstack_storage:/var/www/html/storage/uploads \
-v bookstack_public:/var/www/html/public/uploads \
-e BOOKSTACK_ADMIN_EMAIL=admin@example.com \
-e BOOKSTACK_ADMIN_PASSWORD=changeme123 \
-e BOOKSTACK_ADMIN_NAME=Admin \
-e TZ=UTC \
-e BOOKSTACK_APP_URL=http://localhost:8080 \
-e DB_HOST=your-db-host \
-e DB_DATABASE=bookstack \
-e DB_USERNAME=bookstack \
-e DB_PASSWORD=your-db-password \
--restart unless-stopped \
bookstack-
Access BookStack: Navigate to
http://localhost:8080 -
First Login:
- Email: The email you set via
BOOKSTACK_ADMIN_EMAIL - Password: The password you set via
BOOKSTACK_ADMIN_PASSWORD
- Email: The email you set via
-
Configure Settings:
- Go to Settings (gear icon) to configure your BookStack instance
- Update site name, registration settings, and other preferences
-
Security:
- Use a strong password from the start via
BOOKSTACK_ADMIN_PASSWORD - Configure email settings for password resets and notifications
- Consider changing the admin email address in BookStack settings after first login
- Use a strong password from the start via
BOOKSTACK_ADMIN_EMAIL: Admin email address (REQUIRED)BOOKSTACK_ADMIN_PASSWORD: Admin password (REQUIRED)TZ: Timezone (REQUIRED) - See TIMEZONES.md or WikipediaDB_HOST: Database host (REQUIRED)DB_DATABASE: Database name (REQUIRED)DB_USERNAME: Database username (REQUIRED)DB_PASSWORD: Database password (REQUIRED)
BOOKSTACK_ADMIN_NAME: Admin display name (default: "Admin")BOOKSTACK_APP_URL: Application URL (default: "http://localhost:8080")DB_PORT: Database port (default: 3306)
BookStack stores uploaded files in two locations:
/var/www/html/storage/uploads: Internal storage for file uploads (images, attachments, etc.)/var/www/html/public/uploads: Public uploaded files
These volumes should be mounted to ensure data persists across container restarts:
-v bookstack_storage:/var/www/html/storage/uploads \
-v bookstack_public:/var/www/html/public/uploads80: HTTP port (mapped to8080in the examples above)
BookStack requires a MySQL or MariaDB database. You can use:
- A managed database service
- A separate MariaDB/MySQL container
- An existing MySQL/MariaDB server on your network
Configure the database connection via environment variables:
DB_HOST- Database host (REQUIRED)DB_PORT- Database port (default: 3306)DB_DATABASE- Database name (REQUIRED)DB_USERNAME- Database username (REQUIRED)DB_PASSWORD- Database password (REQUIRED)
- Use HTTPS: Always use HTTPS in production (consider a reverse proxy like Traefik or nginx)
- Strong Passwords: Use strong, unique passwords for the admin account
- Secure Volumes: The database and uploads volumes contain sensitive information
- Regular Updates: Keep the container updated with the latest BookStack version
- Disable Registration: Public registration is disabled by default - enable only if needed
- Firewall: Consider restricting access to the container/port
BOOKSTACK_VERSION: BookStack version to download (default: v24.10.1)
# Build with default version
docker build -t bookstack .
# Build with specific version
docker build --build-arg BOOKSTACK_VERSION=v24.10 -t bookstack .
# Build with latest release
docker build --build-arg BOOKSTACK_VERSION=release -t bookstack .Note: Check BookStack releases for available versions.
All required variables must be provided:
# Basic setup with required variables
docker run -d \
--name bookstack \
-p 8080:80 \
-v bookstack_storage:/var/www/html/storage/uploads \
-v bookstack_public:/var/www/html/public/uploads \
-e BOOKSTACK_ADMIN_EMAIL=admin@example.com \
-e BOOKSTACK_ADMIN_PASSWORD=MySecurePass123! \
-e TZ=Europe/London \
-e DB_HOST=mariadb.example.com \
-e DB_DATABASE=bookstack \
-e DB_USERNAME=bookstack \
-e DB_PASSWORD=dbpassword \
--restart unless-stopped \
bookstack
# With custom admin name and app URL
docker run -d \
--name bookstack \
-p 8080:80 \
-v bookstack_storage:/var/www/html/storage/uploads \
-v bookstack_public:/var/www/html/public/uploads \
-e BOOKSTACK_ADMIN_EMAIL=johndoe@example.com \
-e BOOKSTACK_ADMIN_PASSWORD=MySecurePass123! \
-e BOOKSTACK_ADMIN_NAME="John Doe" \
-e BOOKSTACK_APP_URL=https://wiki.mycompany.com \
-e TZ=America/Chicago \
-e DB_HOST=db.internal \
-e DB_DATABASE=bookstack \
-e DB_USERNAME=bookstack_user \
-e DB_PASSWORD=secure_db_pass \
--restart unless-stopped \
bookstackFor a complete list of timezone identifiers, see:
- TIMEZONES.md - Common timezones included in this repository
- Wikipedia List - Complete timezone database
- IANA Time Zone Database - Official timezone database
Common examples: America/New_York, Europe/London, Asia/Tokyo, UTC
Note: The container will not start without the required environment variables: BOOKSTACK_ADMIN_EMAIL, BOOKSTACK_ADMIN_PASSWORD, TZ, DB_HOST, DB_DATABASE, DB_USERNAME, and DB_PASSWORD.
To backup your BookStack data:
# Backup storage uploads
docker run --rm \
-v bookstack_storage:/data \
-v $(pwd)/backup:/backup \
alpine tar czf /backup/bookstack-storage-$(date +%Y%m%d).tar.gz -C /data .
# Backup public uploads
docker run --rm \
-v bookstack_public:/data \
-v $(pwd)/backup:/backup \
alpine tar czf /backup/bookstack-public-$(date +%Y%m%d).tar.gz -C /data .Note: Database backups should be done using your MySQL/MariaDB database backup tools (mysqldump, etc.).
# Restore storage uploads
docker run --rm \
-v bookstack_storage:/data \
-v $(pwd)/backup:/backup \
alpine sh -c "cd /data && tar xzf /backup/bookstack-storage-YYYYMMDD.tar.gz"
# Restore public uploads
docker run --rm \
-v bookstack_public:/data \
-v $(pwd)/backup:/backup \
alpine sh -c "cd /data && tar xzf /backup/bookstack-public-YYYYMMDD.tar.gz"Note: Database restoration should be done using your MySQL/MariaDB database restore tools.
If you forget the admin password:
# Method 1: Restart container (admin credentials are updated on every start)
docker stop bookstack
docker rm bookstack
docker run -d \
--name bookstack \
-p 8080:80 \
-v bookstack_storage:/var/www/html/storage/uploads \
-v bookstack_public:/var/www/html/public/uploads \
-e BOOKSTACK_ADMIN_EMAIL=admin@example.com \
-e BOOKSTACK_ADMIN_PASSWORD=NewPassword123 \
-e TZ=UTC \
-e DB_HOST=your-db-host \
-e DB_DATABASE=bookstack \
-e DB_USERNAME=bookstack \
-e DB_PASSWORD=your-db-password \
bookstack
# Method 2: Use artisan command directly
docker exec -it bookstack php artisan bookstack:reset-password --email=admin@example.com --password=NewPassword123- PHP Extensions: All required extensions are included in this Docker image
- Memory: 256MB RAM minimum, 512MB recommended
- Database: MySQL 5.7+ or MariaDB 10.2+ (external database required)
- Storage:
- ~200MB for application
- Additional space for uploads (varies by usage)
# Container logs
docker logs bookstack
# Follow logs in real-time
docker logs -f bookstack
# Apache logs
docker exec bookstack tail -f /var/log/apache2/error.log
docker exec bookstack tail -f /var/log/apache2/access.log
# BookStack logs
docker exec bookstack tail -f /var/www/html/storage/logs/laravel.log# Fix permissions if needed
docker exec bookstack chown -R www-data:www-data /var/www/html/storage
docker exec bookstack chown -R www-data:www-data /var/www/html/public/uploads
docker exec bookstack chmod -R 755 /var/www/html/storage# Test database connection
docker exec bookstack php artisan tinker --execute="echo DB::connection()->getPdo() ? 'Connected' : 'Failed';"
# Run migrations manually
docker exec bookstack php artisan migrate --force
# Clear cache
docker exec bookstack php artisan cache:clear
docker exec bookstack php artisan config:clear
docker exec bookstack php artisan view:clear- Check that all required environment variables are set
- Verify volumes are accessible
- Check logs:
docker logs bookstack - Ensure port 8080 (or your chosen port) is not already in use
To update to a newer version of BookStack:
- Backup your data (see Backup section above)
- Update the
BOOKSTACK_VERSIONin the Dockerfile or docker-compose.yml - Rebuild and restart:
# Stop and remove old container
docker stop bookstack
docker rm bookstack
# Rebuild with new version
docker build --no-cache -t bookstack .
# Start with same volumes and database (data persists)
docker run -d \
--name bookstack \
-p 8080:80 \
-v bookstack_storage:/var/www/html/storage/uploads \
-v bookstack_public:/var/www/html/public/uploads \
-e BOOKSTACK_ADMIN_EMAIL=admin@example.com \
-e BOOKSTACK_ADMIN_PASSWORD=changeme123 \
-e TZ=UTC \
-e DB_HOST=your-db-host \
-e DB_DATABASE=bookstack \
-e DB_USERNAME=bookstack \
-e DB_PASSWORD=your-db-password \
--restart unless-stopped \
bookstackThe entrypoint script will automatically run migrations on container start.
By default, email is not configured. To enable email notifications and password resets:
- Access the container:
docker exec -it bookstack bash- Edit the
.envfile:
nano /var/www/html/.env- Update the mail settings:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_FROM=your-email@gmail.com
MAIL_FROM_NAME=BookStack
MAIL_ENCRYPTION=tls
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password- Restart the container:
docker restart bookstackFeel free to contribute improvements, bug fixes, or feature requests.
This Docker configuration is provided as-is under BSD 2-Clause License. BookStack itself is licensed under MIT License.
- Docker Hub Image - Pre-built images
- BookStack Official Website
- BookStack GitHub Repository
- BookStack Documentation
- BookStack Demo
This Docker solution is inspired by the SnappyMail Docker project structure.