Instant Wiki.js with Docker

PUBLISHED ON 07/02/2021 — EDITED ON 17/03/2021 — SYSOPS


This could maybe be a little intro to docker, or not.

In this crazy short tutorial, we will see how to deploy a working Wiki.js instance in 10 commands with Docker.

Please note, this setup is useful for testing purposes. To make it to production, we should really look into Linux hardening and configure the server properly. The recommended database for Wiki.js is Postgres and support for other backends will be dropped in the future, they also specificly state that SQlite is not meant for production use.

Quick and bad way for learning purposes

Preparing the server

Create a new node/server with Debian 10 on your favourite provider.

Log in the server as root.

$ ssh root@wonderfulnewinstance -i throw-a-key-for-a-good-measure

10 commands until deployment


root@localhost:~# apt-get update
root@localhost:~# apt-get upgrade
root@localhost:~# apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
root@localhost:~# curl -fsSL | sudo apt-key add -
root@localhost:~# apt-key fingerprint 0EBFCD88
root@localhost:~# add-apt-repository    "deb [arch=amd64] \
   $(lsb_release -cs) \
root@localhost:~# apt-get update
root@localhost:~# apt-get install docker-ce docker-ce-cli
root@localhost:~# docker pull requarks/wiki
root@localhost:~# docker run -d -p 8080:3000 --name wiki --restart unless-stopped -e "DB_TYPE=sqlite" requarks/wiki

BAM, done!

Visit http://IP-OF-INSTANCE:8080 and configure your shiny new wiki.

docker run command explained

So to convert the image to container and run it, we used:

root@localhost:~# docker run -d -p 8080:3000 --name wiki --restart unless-stopped -e "DB_TYPE=sqlite" requarks/wiki

-d run container detached

-p 8080:3000 bind port 8080 on host to port 3000 on container

--name wiki name the container, so we can easier manage it

--restart unless-stopped keep the container running until we say so

-e "DB_TYPE=sqlite" set environment variable, in our case defining which backend database should wikijs use

requarks/wiki image name

Final words

Do not forget to nuke the instance from the orbit, as the safety is questionable. Also, if you have created the instance on some popular cloud provider, deleting the instance prevents the billing.

Random docker commands

Other docker commands one can find useful.

List images on your system:

root@localhost:~# docker images
requarks/wiki   latest    f439bc73d690   3 months ago   429MB

List running containers:

root@localhost:~# docker ps
CONTAINER ID   IMAGE           COMMAND                  CREATED      STATUS      PORTS                              NAMES
5606d1a1c78b   requarks/wiki   "docker-entrypoint.s…"   2 days ago   Up 2 days   3443/tcp,>3000/tcp   wiki

List all containers

root@localhost:~# docker ps -a
CONTAINER ID   IMAGE           COMMAND                  CREATED      STATUS                  PORTS                              NAMES
5606d1a1c78b   requarks/wiki   "docker-entrypoint.s…"   2 days ago   Up 2 days               3443/tcp,>3000/tcp   wiki
7ad0c31fcfce   requarks/wiki   "docker-entrypoint.s…"   2 days ago   Exited (1) 2 days ago                                      amazing_black

Remove a container:

root@localhost:~# docker rm amazing_black

List all volumes

root@localhost:~# docker volume ls

View logs of a container:

root@localhost:~# docker logs wiki
Loading configuration from /wiki/config.yml... OK
2021-02-05T09:48:12.885Z [MASTER] info: =======================================
2021-02-05T09:48:12.887Z [MASTER] info: = Wiki.js 2.5.170 =====================
2021-02-05T09:48:12.888Z [MASTER] info: =======================================
2021-02-05T09:48:12.888Z [MASTER] info: Initializing...

Get a shell in container:

root@localhost:~# docker exec -it wiki /bin/bash

In contrast to run that works with images, after you use it to create a container, you can work with it via:

docker start wiki
docker stop wiki

Better way with docker-compose

Create a new folder for your project and name it carefully (the name gets used in the life of the container). Create a file:


version: "3"

    image: postgres:11-alpine
      POSTGRES_DB: wiki
      POSTGRES_PASSWORD: wikijsrocks
      POSTGRES_USER: wikijs
      driver: "none"
    restart: unless-stopped
      - db-data:/var/lib/postgresql/data

    image: requarks/wiki:2
      - db
      DB_TYPE: postgres
      DB_HOST: db
      DB_PORT: 5432
      DB_USER: wikijs
      DB_PASS: wikijsrocks
      DB_NAME: wiki
    restart: unless-stopped
      - "80:3000"


Watch out for indentation!

Pro tip, if you specify multiple services in one compose file, the common network will be automatically created.

$ docker-compose up

To bring everything down at once:

$ docker-compose down

To update images:

$ docker-compose pull

To access the PostgreSQL database inside docker:

root@localhost:~# docker exec -it root_db_1 /bin/bash

bash-5.1# psql -p 5432 -d wiki -U wikijs -h localhost

See Also