Install and run an Mediawiki instance with docker.
docker run --name mysql -e MYSQL_ROOT_PASSWORD=diouxx -e MYSQL_DATABASE=wikidb -e MYSQL_USER=wiki_user -e MYSQL_PASSWORD=wiki -d mysql:5.7.25
docker run --name mediawiki --link mysql:mysql -p 80:80 -d diouxx/mediawiki
docker run --name wiki --link yourdatabase:mysql -p 80:80 -d diouxx/mediawiki
For an usage on production environnement or daily usage, it's recommanded to use container with volume to persistent data.
- First, create MySQL container with volume
docker run --name mysql -e MYSQL_ROOT_PASSWORD=diouxx -e MYSQL_DATABASE=wikidb -e MYSQL_USER=wiki_user -e MYSQL_PASSWORD=wiki --volume /var/lib/mysql:/var/lib/mysql -d mysql:5.7.25
- Then, create Mediawiki container with volume and link MySQL container
docker run --name wiki --link mysql:mysql --volume /var/www/html/wiki:/var/www/html/wiki -p 80:80 -d diouxx/mediawiki
Enjoy :)
version: "3.2"
services:
#Mysql Container
mysql:
image: mysql:5.7.23
container_name: mysql
hostname: mysql
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=wikidb
- MYSQL_USER=wiki_user
- MYSQL_PASSWORD=wiki
#Mediawiki Container
mediawiki:
image: diouxx/mediawiki
container_name : wiki
hostname: wiki
ports:
- "80:80"
To deploy with docker compose, you use docker-compose.yml and mysql.env file. You can modify mysql.env to personalize settings like :
- MySQL root password
- Mediawiki database
- Mediawiki user database
- Mediawiki user password
MYSQL_ROOT_PASSWORD=diouxx
MYSQL_DATABASE=wikidb
MYSQL_USER=wiki_user
MYSQL_PASSWORD=wiki
version: "3.2"
services:
#Mysql Container
mysql:
image: mysql:5.7.23
container_name: mysql
hostname: mysql
volumes:
- /var/lib/mysql:/var/lib/mysql
env_file:
- ./mysql.env
restart: always
#Mediawiki Container
mediawiki:
image: diouxx/mediawiki
container_name : wiki
hostname: wiki
ports:
- "80:80"
volumes:
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
- /var/www/html/wiki/:/var/www/html/wiki
restart: always
To deploy, just run the following command on the same directory as files
docker-compose up -d