How to Install Linkwarden on Portainer: Step-by-Step Guide

If you’re looking for an efficient way to manage and organize your bookmarks, Linkwarden is the perfect solution. This open-source, self-hosted bookmark manager helps you save, categorize, and access your favorite links with ease. In this guide, we’ll show you how to install Linkwarden on Portainer, a powerful container management tool, to simplify deployment and monitoring. By the end of this tutorial, you’ll have a fully functional Linkwarden instance running on your server.

What is Linkwarden?

Linkwarden is a self-hosted solution designed for individuals and teams to manage bookmarks efficiently. It features tagging, link previews, and integration with tools like PostgreSQL for reliable data management. Hosting it on Portainer simplifies container orchestration and provides an intuitive interface for monitoring and managing Linkwarden.

Prerequisites

Before you begin, ensure you have the following:

  1. Portainer installed and running on your server. If you haven’t installed Portainer yet, refer to Portainer’s official documentation.
  2. Docker and Docker Compose installed.
  3. A basic understanding of container networks and volumes.

Docker Compose Configuration

Use the following docker-compose.yml file to configure Linkwarden and its PostgreSQL database:

services:
  linkwarden:
    container_name: linkwarden
    image: ghcr.io/linkwarden/linkwarden:latest
    restart: unless-stopped
    volumes:
      - /your_path/linkwarden/data:/data/data
    environment:
      - DATABASE_URL=postgresql://dbuser1:PASSWORD@linkwarden-db:5432/linkwarden
      - NEXTAUTH_SECRET=SuperPassword
      - NEXTAUTH_URL=http://localhost/api/v1/auth
    ports:
      - "4222:3000"
    networks:
      - linkwarden_net

  linkwarden-db:
    container_name: linkwarden-db
    image: postgres:16-alpine
    restart: unless-stopped
    environment:
      - POSTGRES_USER=dbuser1
      - POSTGRES_PASSWORD=PASSWORD
      - POSTGRES_DB=linkwarden
    volumes:
      - /your_path/linkwarden/pgdata:/var/lib/postgresql/data
    networks:
      - linkwarden_net

networks:
  linkwarden_net:
    driver: bridge

You will need to update the database connection string and replace PASSWORD with your desired password:

DATABASE_URL=postgresql://dbuser1:PASSWORD@linkwarden-db:5432/linkwarden

Ensure that the password matches the value set for:

- POSTGRES_PASSWORD=PASSWORD

Additionally, replace SuperPassword in:

- NEXTAUTH_SECRET=SuperPassword

with a secure password of your choice.

Lastly, update the paths to your desired directories:

- /your_path/linkwarden/data:/data/data  
- /your_path/linkwarden/pgdata:/var/lib/postgresql/data

Replace /your_path with the actual directory path where you want the data to be stored on your server.

Explanation of the Key Elements:

  • Services:
    • linkwarden: The main service hosting the Linkwarden application.
    • linkwarden-db: The PostgreSQL database storing your Linkwarden data.
  • Volumes: Ensure persistent storage of your data and database.
  • Environment Variables:
    • DATABASE_URL: Connects the app to the PostgreSQL instance.
    • NEXTAUTH_SECRET: A secret key for authentication. Replace SuperPassword with a secure value.
    • NEXTAUTH_URL: Specifies the API endpoint for authentication.
  • Networks: Creates a bridge network to allow seamless communication between services.

Deploy the Stack on Portainer

  1. In Portainer, go to the Stacks section.
  2. Click Add Stack.
  3. Name your stack, e.g., linkwarden-stack.
  4. Paste the provided docker-compose.yml configuration into the editor.
  5. Click Deploy the Stack.

Verify the Deployment

  • Navigate to the Containers section in Portainer
  • Ensure both the linkwarden and linkwarden-db containers are running.
  • Open a web browser and go to http://<your-server-ip>:4222 to access the Linkwarden interface.

Troubleshooting Tips

Database Connection Issues:

  • Double-check the DATABASE_URL value in the configuration file.
  • Verify that the linkwarden-db service is running.

Port Conflicts:

  • If port 4222 is already in use, modify the ports section in the configuration:
ports:
  - "your-preferred-port:3000"

Conclusion

Setting up Linkwarden on Portainer using Docker Compose is an efficient way to manage your bookmarks with complete control over your data. By following this guide, you’ll have Linkwarden up and running in no time, giving you a powerful tool to organize and retrieve links effortlessly.

For more tutorials and insights on containerized applications, bookmark arstech.net! 🚀

arstech