Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Deploy Your Own Wiki With WikiJS and Docker

I am looking into finding a decent open source wiki. I spent ages trying to get WikiJS up and running to evaluate it. Unfortunately, I don't think it's suitable for me, but wanted to post this to save other people the pain I had to go through in order to figure out how to get it set up. Perhaps one day the system will be improved to make it worthwhile.


The first thing we need to do is create a configuration file for our wiki. Use the following commands to open up the vim text editor in the relevant place:

mkdir -p $HOME/volumes/wiki
cd $HOME/volumes/wiki
mv config.sample.yml config.yml

For security, we need to change the session secret to something random. The script below will do this for you.

SEARCH="sessionSecret: 1234567890abcdefghijklmnopqrstuvxyz"
REPLACE="sessionSecret: `openssl rand -base64 32`"

As we will be using a container for our Mongo DB, we also need to change the database parameter in the config:


Setting Up Git

The wiki needs to connect to a git repository in order to be able to version control the wiki. As I intend to store sensitive information on the wiki and only have it accessible on a company intranet, it would defeat the purpose if I had it posting everything to a public Github repo. Instead, I am going to set it up with a repository in my private Gitlab server. I created a new account on my Gitlab server using a Gmail alias, then generated an ssh-key on the server without a passphrase and set that up for the wikijs user in Gitlab before then creating a repository for the wiki. Thus the wikijs server will have a key that can only access the one repository in Gitlab.

To copy the private SSH key to where we will need it for a volume mount, use:

cp $HOME/.ssh/id_rsa $HOME/volumes/wiki/git-ssh-key.pem

Review Git Config

After having set up your git repository, review the Git connection Info in your configuration file and update it accordingly. I have pasted mine below for reference:

vim $HOME/volumes/wiki/config.yml
# ---------------------------------------------------------------------
# Git Connection Info
# ---------------------------------------------------------------------

  branch: master

    # Type: basic or ssh
    type: ssh

    # Only for Basic authentication:
    username: wikijs
    password: myRandomPassword

    # Only for SSH authentication:
    privateKey: /etc/wiki/keys/git.pem

    #sslVerify: true

    # Default email to use as commit author

    # Whether to use user email as author in commits
    showUserEmail: false

Deploy With Docker Compose

Install docker-compose if you haven't already.

Copy/paste the following docker-compose.yml file to your server.

version: '3'
    image: mongo:3
      - '27017'
    command: '--smallfiles --bind_ip ::,'
      - 'MONGO_LOG_DIR=/dev/null'
      - $HOME/volumes/mongo/db:/data/db
    image: 'requarks/wiki:latest'
      - wikidb
      - wikidb
      - '80:80'
      - $HOME/volumes/wiki/config.yml:/var/wiki/config.yml
      - $HOME/volumes/wiki/git-ssh-key.pem:/etc/wiki/keys/git.pem

Don't forget to change to your email address.

For reference, the docker-compose.yml file is a tweaked version from here.

Now spin up your wiki and mongo containers, with the appropriate volumes by running:

docker-compose up

Now navigate to your server's IP address or domain and you should see the screen below:

Login with the WIKI_ADMIN_EMAIL you specified in the docker-compose.yml file, and use the password admin123.

You should then see the following page:

When I clicked on Create Home Page I was greeted with the following:

I couldn't figure out how to save, and gave up at this point because the whole thing looks butt ugly and I could have probably developed something better suited to my needs in less time than it took to set this thing up.


If you experience issues, the best thing to do is to enter the wiki container, and then go into the /logs directory and view the error logs using cat. Alternatively, you could alter your docker-compose.yml file so that the /logs folder is a volume so that you can access the logs from the host.