A production-ready Docker Compose configuration for Linkwarden - a self-hosted bookmark manager with AI-powered tagging capabilities.
- Portainer Compatible - Optimized for deployment via Portainer stacks
- OpenAI Integration - Built-in AI tagging using OpenAI's GPT models
- PostgreSQL 16 - Reliable database backend with persistent storage
- Environment-based Configuration - All secrets managed via
.envfile - Security Hardened - No hardcoded credentials, proper network isolation
Linkwarden is a self-hosted, open-source collaborative bookmark manager to collect, organize and archive webpages. It supports tagging, categorization, and AI-powered content analysis.
- Docker and Docker Compose installed
- OpenAI API key (optional, for AI tagging feature)
- Minimum 2GB RAM recommended
- Portainer (optional, but recommended for easy management)
git clone https://github.com/christancho/linkwarden-docker-compose.git
cd linkwarden-docker-composeCopy the example environment file and edit it:
cp .env.example .env
nano .envUpdate the following required variables in .env:
# PostgreSQL Configuration
POSTGRES_PASSWORD=your_secure_postgres_password
# Linkwarden Configuration
NEXTAUTH_SECRET=your_secure_nextauth_secret # Generate with: openssl rand -base64 32
NEXTAUTH_URL=http://localhost:4000/api/v1/auth
# Data Directory
LINK_DIR=/path/to/your/linkwarden/data # Absolute path where data will be stored
# OpenAI Configuration (Optional - for AI tagging)
OPENAI_API_KEY=sk-your-openai-api-key-here
OPENAI_MODEL=gpt-4o# Generate NEXTAUTH_SECRET
openssl rand -base64 32docker-compose up -d- Log in to your Portainer instance
- Navigate to Stacks > Add Stack
- Name your stack (e.g.,
linkwarden) - Choose Git Repository or Upload method:
- Git Repository: Paste this repository URL
- Upload: Copy contents of
docker-compose.yml
- Add environment variables from your
.envfile in the Environment variables section - Click Deploy the stack
Open your browser and navigate to:
http://localhost:4000
Or replace localhost with your server's IP address.
This setup includes OpenAI integration for AI-powered bookmark tagging. The AI can automatically:
- Analyze bookmark content
- Generate relevant tags and keywords
- Improve searchability and organization
To enable AI tagging:
- Get an OpenAI API key from https://platform.openai.com/api-keys
- Add it to your
.envfile:OPENAI_API_KEY=sk-proj-your-actual-key-here OPENAI_MODEL=gpt-4o
- Restart the container:
docker-compose restart linkwarden # OR via Portainer: Select stack > Restart
gpt-4o- Most capable, higher costgpt-4o-mini- Balanced performance and costgpt-3.5-turbo- Fastest, lowest cost
If using an OpenAI-compatible provider (not official OpenAI), add:
CUSTOM_OPENAI_BASE_URL=https://your-custom-endpoint.com| Variable | Description | Required | Default |
|---|---|---|---|
POSTGRES_PASSWORD |
PostgreSQL database password | Yes | - |
NEXTAUTH_SECRET |
Secret for authentication sessions | Yes | - |
NEXTAUTH_URL |
Authentication callback URL | Yes | http://localhost:4000/api/v1/auth |
LINK_DIR |
Directory for persistent data storage | Yes | - |
OPENAI_API_KEY |
OpenAI API key for AI tagging | No | - |
OPENAI_MODEL |
OpenAI model to use | No | gpt-4o |
CUSTOM_OPENAI_BASE_URL |
Custom OpenAI-compatible endpoint | No | OpenAI's API |
- 4000 - Linkwarden web interface (mapped from container port 3000)
- 5432 - PostgreSQL (internal network only)
Data is persisted in the directory specified by LINK_DIR:
${LINK_DIR}/pgdata- PostgreSQL database files${LINK_DIR}/data- Linkwarden application data
- Stack Environment Variables: When deploying via Portainer, add each environment variable individually in the stack configuration UI
- Volume Paths: Ensure
LINK_DIRpoints to a directory accessible by the Portainer agent - Updates: To update Linkwarden, pull the latest image via Portainer's Recreate function
- Logs: Monitor container logs directly in Portainer's Logs tab
docker-compose pull
docker-compose up -d- Navigate to your stack
- Click Update the stack
- Enable Re-pull image and redeploy
- Click Update
It's recommended to regularly backup your data directory:
# Backup PostgreSQL data and Linkwarden files
tar -czf linkwarden-backup-$(date +%Y%m%d).tar.gz ${LINK_DIR}/- Check logs:
docker-compose logs linkwarden - Verify all required environment variables are set
- Ensure
LINK_DIRexists and has proper permissions
- Verify
OPENAI_API_KEYis correctly set - Check API key has sufficient credits at https://platform.openai.com/usage
- Review container logs for API errors
- Verify port 4000 is not in use:
lsof -i :4000 - Check firewall settings
- Ensure
NEXTAUTH_URLmatches your access URL
- Never commit
.envfile to version control - Use strong passwords for
POSTGRES_PASSWORD - Regenerate
NEXTAUTH_SECRETregularly - Consider using a reverse proxy (Nginx, Traefik) with SSL in production
- Restrict OpenAI API key permissions if possible
- Monitor OpenAI API usage to prevent unexpected costs
Contributions are welcome! Please feel free to submit a Pull Request.
This Docker Compose configuration is licensed under the Apache License 2.0. See LICENSE for details.
Linkwarden itself is licensed under the AGPLv3 License.
- Linkwarden Official Website
- Linkwarden GitHub Repository
- Linkwarden Documentation
- Portainer Documentation
- OpenAI Platform
For issues related to:
- This Docker setup: Open an issue in this repository
- Linkwarden application: Visit Linkwarden's GitHub
- OpenAI API: Check OpenAI's documentation