Install Wiki.js Inside Docker Container in Linux

Install Wiki.js Inside Docker Container in Linux

Wiki.js is a web-based wiki application that running on Node.js. Wiki.js is an open-source project that released under the AGPL license.

This tutorial explains how to install Wiki.js inside a Docker container in the Linux. Commands have been tested on Ubuntu.

Prepare environment

Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.

You also need to have a running MySQL container. Instructions can be found in the post.

Install Wiki.js

Before starting, create wikijs database:

docker exec -it mysql mysql -u root -p -e "CREATE DATABASE wikijs"
  • Host network

Run the following command to create a container for Wiki.js that uses host network:

docker run -d --name=wikijs --restart=always --network=host \
    -v /opt/wikijs/data:/wiki/data/content \
    -e DB_TYPE=mysql \
    -e DB_USER=root \
    -e DB_PASS=pwd123 \
    -e DB_NAME=wikijs \
    -e DB_PORT=3306 \
    -e DB_HOST=127.0.0.1 \
    requarks/wiki

MySQL container should run on host network as well.

  • User-defined bridge network

User-defined bridge network can be used for listening on different port. By default, Wiki.js service is listening on port 3000. It can be changed with -p option.

docker network create app-net
docker run -d --name=wikijs --restart=always --network=app-net \
    -p 8080:3000 \
    -v /opt/wikijs/data:/wiki/data/content \
    -e DB_TYPE=mysql \
    -e DB_USER=root \
    -e DB_PASS=pwd123 \
    -e DB_NAME=wikijs \
    -e DB_PORT=3306 \
    -e DB_HOST=mysql \
    requarks/wiki

MySQL container should run on the same user-defined bridge network as well.

Notes:

  • The DB_USER and DB_PASS can be used to specify MySQL credentials.
  • When user-defined bridge network is used, don't forget to change DB_HOST. It specifies MySQL container name.

Testing Wiki.js

Open a web browser and go to http://<IP_ADDRESS>:3000, where <IP_ADDRESS> is the IP address of the system. For the first time, you will be asked to create the administrator account. After that, you will be able to log in to the dashboard.

Wiki.js Inside Docker Container in Linux

Uninstall Wiki.js

To completely remove Wiki.js, remove its container:

docker rm --force wikijs

Remove Wiki.js image:

docker rmi requarks/wiki

You can also remove Wiki.js data:

sudo rm -rf /opt/wikijs

If a user-defined bridge network was created, you can delete it as follows:

docker network rm app-net

Leave a Comment

Cancel reply

Your email address will not be published.