Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
| engineering:computer_science:docker:application_guides:docker_dokuwiki_portable [2024/08/16 15:05] – removed - external edit (Unknown date) 127.0.0.1 | engineering:computer_science:docker:application_guides:docker_dokuwiki_portable [2024/08/16 15:05] (current) – ↷ Page moved from engineering:computer_science:docker:docker_dokuwiki_portable to engineering:computer_science:docker:application_guides:docker_dokuwiki_portable carlossousa | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Docker - DokuWiki (with docker volume host directory for portability and direct access to data) ====== | ||
| + | |||
| + | The main objective is to have: | ||
| + | |||
| + | - Easy to backup / restore data from DokuWiki a.k.a. sleeping with mind at ease. | ||
| + | - Easy portability a.k.a. I can have the Wiki run from my own Laptop in case of a major failure | ||
| + | - Small footprint a.k.a. A VM would take something between 10-20 GB to take with me. This way I can take the Docker Image and it's data in less then 2 GB. | ||
| + | |||
| + | This documentation was done using **Ubuntu Server 20.04 LTS** as a VirtualMachine, | ||
| + | |||
| + | This documentation was also used successfully to deploy to a VPS. | ||
| + | |||
| + | I will be using a pre-made image from [[https:// | ||
| + | |||
| + | I'm assuming you already have Docker and Docker-Compose installed. | ||
| + | |||
| + | If not, go ahead and install them: | ||
| + | |||
| + | <code bash> | ||
| + | sudo apt install docker -y && sudo apt install docker-compose -y | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ===== Preparations due to LVM ===== | ||
| + | |||
| + | First, after installing Ubuntu, we should expand the LVM to use the entire Free Space available. This is/was an issue at the time of writing (17/ | ||
| + | |||
| + | <code bash> | ||
| + | sudo lvm | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | <code bash> | ||
| + | lvextend -l +100%FREE / | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | <code bash> | ||
| + | exit | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | <code bash> | ||
| + | sudo resize2fs / | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | Confirm with: | ||
| + | |||
| + | <code bash> | ||
| + | df -h | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | ---- | ||
| + | |||
| + | |||
| + | ===== Avoiding "sudo docker command" | ||
| + | |||
| + | Let's add ourselfs to the Docker Group so we don't have to prefix every Docker command with ' | ||
| + | |||
| + | <code bash> | ||
| + | sudo gpasswd -a $USER docker | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ===== Creating the Volumes for Data ===== | ||
| + | |||
| + | Now we need to create the docker volumes, which points to a local folder, so we can manipulate / migrate / backup the data easily if needed. | ||
| + | |||
| + | ^General Example^Pratical Example| | ||
| + | |<code bash> | ||
| + | docker volume create \ | ||
| + | --driver local \ | ||
| + | --opt type=none \ | ||
| + | --opt device=/ | ||
| + | --opt o=bind \ | ||
| + | test_vol | ||
| + | |||
| + | |||
| + | </ | ||
| + | docker volume create \ | ||
| + | --driver local \ | ||
| + | --opt type=none \ | ||
| + | --opt device=/ | ||
| + | --opt o=bind dokuwiki_data | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | We can either create all volumes and directories necessary manually, or use this script - **create_volumes.sh** | ||
| + | |||
| + | <code bash> | ||
| + | #!/bin/bash | ||
| + | STORAGE_PATH="/ | ||
| + | mkdir -p " | ||
| + | docker volume create --driver local --opt type=none --opt device=" | ||
| + | docker volume create --driver local --opt type=none --opt device=" | ||
| + | docker volume create --driver local --opt type=none --opt device=" | ||
| + | docker volume create --driver local --opt type=none --opt device=" | ||
| + | docker volume create --driver local --opt type=none --opt device=" | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ===== Creating the docker-compose.yml file ===== | ||
| + | |||
| + | After that we can create our **docker-compose.yml** | ||
| + | |||
| + | <code bash> | ||
| + | version: ' | ||
| + | |||
| + | 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: ' | ||
| + | ports: | ||
| + | - ' | ||
| + | volumes: | ||
| + | - dokuwiki_data:/ | ||
| + | - dokuwiki_conf:/ | ||
| + | - dokuwiki_lib-plugins:/ | ||
| + | - dokuwiki_lib-tpl:/ | ||
| + | - dokuwiki_logs:/ | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ===== Starting the Container ===== | ||
| + | |||
| + | Finally, if you already have Data from your previous DokuWiki, you can just copy/paste them in those previous created folders. Else you will just start a new DokuWiki once you start up the container. A few usefull commands to manage the container with docker-compose | ||
| + | |||
| + | ^Command^Purpose| | ||
| + | |docker-compose up -d|Starts the Container and dettach (so you have your bash prompt back)| | ||
| + | |docker-compose down|Stops the Container| | ||
| + | |docker-compose ps|Checks the status of the Container| | ||
| + | |||
| + | Your container should now be accessible via [[http://< | ||
| + | |||
| + | Do note that https:// isn't available, since the container isn't listening on port 443. // | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ===== Backing Up / Migrating the Data ===== | ||
| + | |||
| + | We can easily migrate the data by grabbing everything in the mounted volumes and collecting them into a tar(ball). | ||
| + | |||
| + | To do that we can create a file called **backtup_to_tar.sh** which when run will grab everything from // | ||
| + | <code bash> | ||
| + | #!/bin/bash | ||
| + | SOURCE_PATH="/ | ||
| + | BACKUP_PATH="/ | ||
| + | BACKUP_NAME=" | ||
| + | tar cvf " | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||