This is an old revision of the document!
Docker - DokuWiki (with docker volume host directory for portability and direct access to data)
This documentation was done using Ubuntu Server 20.04 LTS as a VirtualMachine, virtualized via VirtualBox 6.1.8.
Ubuntu was configured to use LVM.
I'm assuming you already have Docker and Docker-Compose installed.
if not, go ahead and install them (sudo apt-get install docker -y && sudo apt-get install docker-compose -y)
First, after installing Ubuntu, we should expand the LVM to use the entire Fee Space available. This is/was an issue at the time of writing (17/07/2020)
sudo lvm
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
exit
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
Confirm with:
df -h
Let's add ourselfs to the Docker Group so we don't have to prefix every command from Docker with 'sudo'
sudo gpasswd -a $USER docker
Now let's create a docker volume, which points to a local folder, so we can manipulate / migrate / backup the data easily if needed.
General Example | Pratical Example |
---|---|
docker volume create \ --driver local \ --opt type=none \ --opt device=/home/user/test \ --opt o=bind \ test_vol | docker volume create \ --driver local \ --opt type=none \ --opt device=/media/share/UbuntuDocker/dokuwiki/storage/data \ --opt o=bind dokuwiki_data |
We can either create all volumes and directories necessary manually, or use this script to create the folders and volumes in one go:
#!/bin/bash STORAGE_PATH="/home/docker-user/dokuwiki" mkdir -p "$STORAGE_PATH"/storage/{data,conf,lib/plugins,lib/tpl,logs} docker volume create --driver local --opt type=none --opt device="$STORAGE_PATH"/storage/data --opt o=bind dokuwiki_data docker volume create --driver local --opt type=none --opt device="$STORAGE_PATH"/storage/conf --opt o=bind dokuwiki_conf docker volume create --driver local --opt type=none --opt device="$STORAGE_PATH"/storage/lib/plugins --opt o=bind dokuwiki_lib-plugins docker volume create --driver local --opt type=none --opt device="$STORAGE_PATH"/storage/lib/tpl --opt o=bind dokuwiki_lib-tpl docker volume create --driver local --opt type=none --opt device="$STORAGE_PATH"/storage/logs --opt o=bind dokuwiki_logs
After that we can create our docker-compose.yml which will be used to manage our container:
version: '2' volumes: dokuwiki_data: external: true dokuwiki_conf: external: true dokuwiki_lib-plugins: external: true dokuwiki_lib-tpl: external: true dokuwiki_logs: external: true services: dokuwiki: image: 'mprasil/dokuwiki' ports: - '80:80' volumes: - dokuwiki_data:/dokuwiki/data - dokuwiki_conf:/dokuwiki/conf - dokuwiki_lib-plugins:/dokuwiki/lib/plugins - dokuwiki_lib-tpl:/dokuwiki/lib/tpl - dokuwiki_logs:/var/log