Skip to content

Instantly share code, notes, and snippets.

@ifgeny87
Last active December 20, 2023 08:44
Show Gist options
  • Select an option

  • Save ifgeny87/fa4e95c432098e09c430ec7985703b1a to your computer and use it in GitHub Desktop.

Select an option

Save ifgeny87/fa4e95c432098e09c430ec7985703b1a to your computer and use it in GitHub Desktop.

Build and run Docker contrainer with Dokuwiki

Author: Makarov Evgeny Updated: 2023-12-20

Used URLs:

Steps

  1. Run build.sh
  2. Open http://localhost:30312/install.php in your browser
  3. Configure and save your Dokuwiki
  4. Execute bash in docker container and remove the install.php file

Files

Dockerfile

FROM php:7-apache-bullseye

WORKDIR /var/www/html

RUN curl --remote-name https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz
RUN tar -xzvf dokuwiki-stable.tgz --strip-components=1
RUN rm dokuwiki-stable.tgz
RUN chown -R www-data:www-data /var/www/

EXPOSE 80

build.sh

#!/bin/bash -e

# setup names
IMAGE_TAG=dokuwiki:latest
CONTAINER_NAME=dokuwiki
VOLUME_NAME=dokuwiki_data

# stop n delete container
if [[ ! -z "$(docker ps | grep $CONTAINER_NAME)" ]]; then
  docker stop $CONTAINER_NAME
  docker rm $CONTAINER_NAME
fi

# delete image
if [[ ! -z "$(docker image ls | grep $IMAGE_TAG)" ]]; then
  docker image rm $IMAGE_TAG
fi

# create volume if does not exist
if [[ -z "$(docker volume ls | grep $IMAGE_TAG)" ]]; then
  docker volume create $VOLUME_NAME
fi

# build image
docker build --tag $IMAGE_TAG .

# run container
docker run -d \
  --name=$CONTAINER_NAME \
  --restart unless-stopped \
  -v $VOLUME_NAME:/var/www/html \
  -p 30312:80/tcp \
  "$IMAGE_TAG"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment