Step-by-Step Guide: Installing and Configuring Wiki.js with Docker on Debian 12

Wiki.js is a powerful and modern wiki application that runs on Node.js. It has an easy-to-use interface for creating and managing content. It supports various login methods, offers version control, Markdown editing, allowing you to write content with a live preview, and many plugins for added functionality. Additionally, Wiki.js offers full-text search capabilities and customizable themes and branding to tailor the wiki to your specific needs.

Wiki.js can be used for various purposes, including internal documentation, creating a knowledge base, managing personal knowledge, hosting educational resources, developing a community wiki, documenting projects, and planning events.

In this guide, we will install and configure Wiki.js on Debian 12 using Docker.

The setup includes Docker, PostgreSQL 15 (dockerized), Wiki.js 2.x (dockerized and accessible via port 80), Wiki.js Update Companion (dockerized), and OpenSSH with UFW firewall preconfigured for SSH, HTTP, and HTTPS.

Update the system:

Before we begin installing Wiki.js and Docker, it's important to ensure that your system is up-to-date. Use the following commands to update your system.

apt -qqy update
DEBIAN_FRONTEND=noninteractive apt-get -qqy -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' dist-upgrade
Install Docker:

Docker is essential for containerizing Wiki.js and PostgreSQL. First, install the necessary dependencies to install Docker using the following command.

apt -qqy -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install ca-certificates curl gnupg lsb-release

Next, register the Docker package registry to your system.

mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null

Finally, refresh the package updates and install Docker.

apt -qqy update
apt -qqy -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install docker-ce docker-ce-cli containerd.io docker-compose-plugin

By following these steps, you will have Docker installed and ready to use for containerizing your applications.

Setup Containers

You can use the directory name as you wish, but remember to change the commands accordingly if you choose a different directory name.

First, create installation directory for Wiki.js.

mkdir -p /etc/wiki

Next, generate a database secret and save it in the created directory.

openssl rand -base64 32 | tee /etc/wiki/.db-secret

Create an internal Docker network for the containers to communicate.

docker network create wikinet

Create a data volume for PostgreSQL.

docker volume create pgdata

Now, create the containers for PostgreSQL, Wiki.js, and the Wiki.js Update Companion:

docker create --name=db \
    -e POSTGRES_DB=wiki \
    -e POSTGRES_USER=wiki \
    -e POSTGRES_PASSWORD_FILE=/etc/wiki/.db-secret \
    -v /etc/wiki/.db-secret:/etc/wiki/.db-secret:ro \
    -v pgdata:/var/lib/postgresql/data \
    --restart=unless-stopped \
    -h db \
    --network=wikinet \
    postgres:15

docker create --name=wiki \
    -e DB_TYPE=postgres \
    -e DB_HOST=db \
    -e DB_PORT=5432 \
    -e DB_PASS_FILE=/etc/wiki/.db-secret \
    -v /etc/wiki/.db-secret:/etc/wiki/.db-secret:ro \
    -e DB_USER=wiki \
    -e DB_NAME=wiki \
    -e UPGRADE_COMPANION=1 \
    --restart=unless-stopped \
    -h wiki \
    --network=wikinet \
    -p 80:3000 \
    -p 443:3443 \
    ghcr.io/requarks/wiki:2

docker create --name=wiki-update-companion \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
    --restart=unless-stopped \
    -h wiki-update-companion \
    --network=wikinet \
    ghcr.io/requarks/wiki-update-companion:latest

By following these steps, you will have set up the necessary containers for Wiki.js, PostgreSQL, and the update companion, ready to be started and used.

If your server has a firewall enabled, you'll need to allow specific ports to ensure proper access.

ufw allow ssh
ufw allow http
ufw allow https
ufw --force enable
Start the containers

To start the Docker containers for PostgreSQL, Wiki.js, and the Wiki.js Update Companion, execute the following commands:

docker start db
docker start wiki
docker start wiki-update-companion

These commands will initiate the containers, allowing Wiki.js to be accessible and ensuring that the update companion is running to manage updates seamlessly.

Access the setup wizard

To complete the installation of Wiki.js, simply open your web browser and enter the following URL in the address bar:

http://your-server-ip/

Replace your-server-ip with the actual IP address or domain name of your server where Wiki.js is installed.

Now you will see the setup wizard for Wiki.js, where you can follow the on-screen instructions to finalize the installation according to your preferences.



You've successfully installed and configured Wiki.js, which is a powerful and flexible open-source wiki software. With Wiki.js, you can create and manage your wiki with ease.