107Xwiki - amagerard/Docker GitHub Wiki

Docker/Home

RedHat/Docker.

1- Docker 2- Firewall 3- Portainer 4- Drupal 5- Joomla
6-Wordpress 7-Xwiki 8- Mediawiki
Casaos Zimaos

7. Xwiki.

Xwiki is a collaborative platform and written in Java.

This procedure is based on this example.

Docker server ip :192.168.60.55/24
Your username: teacher
Your home directory:/home/teacher

7.1 Create Network and Volumes with Portainer.

Open Portainer for create network and volumes.
http://192.168.60.55:9000

Click on Environments Local.

7.1.1 Each Xwiki instance has its container.

  • cnt_xki_wb_number.
  • cnt_xki_db_number.
    Containers will be created from the docker compose command line.

7.1.2 Each Xwiki instance has its network.

  • net_xki_number.
    Create net_xki_1.
Select Networks.  
Add network.  
Name : net_xki_1  
Add Driver options:  
Name : com.docker.network.bridge.name   value : net_xki_1  
Create the network.  

Name: com.docker.network.bridge.name value : net_xki_1 is not specified, docker will give it a name as br-XXXX.

7.1.3 Each Xwiki instance has its volume.

  • vol_xki_wb_number.
  • vol_xki_db_number.
    Create these volumes.
Select Volumes.  
Add volume.  
Name: vol_xki_wb_1  
Create the volume.  
Add the volume.  
Name: vol_xki_db_1  
Create the volume.  

7.1.4 Information.

Command lines to create the netwok and volumes without portainer.
docker network create --opt com.docker.network.bridge.name=net_xki_1 net_xki_1
docker volume create vol_xki_wb_1
docker volume create vol_xki_db_1

7.2 Give permissions to www-dock and mysql-dock for volumes.

Sorry, Deploying XWiki in the 'ROOT' context.
The user is 0:0 (uid,gid) root. for /var/lib/docker/volumes/vol_xki_wb_1.
chown -R mysql-dock:mysql-dock /var/lib/docker/volumes/vol_xki_db_1

7.3 Install Xwiki with a yaml script.

Logging with your username.
mkdir /home/teacher/xwiki
vi /home/teacher/xwiki/instance_xwiki_1.yaml

# 2025, January  
# replace number  by 1 or 2 or ... until 9  
# example n = 1  
# port published wb = 8081  
# port published db = 33771  
# ip = 192.168.60.55  
# your username is teacher  
# you must create network net_xki_1    from portainer before installing xwiki.  
# you must create volume vol_xki_wb_1  from portainer before installing xwiki.  
# you must create volume vol_xki_db_1  from portainer before installing xwiki.  
# you must create init.sql  file  under /home/teacher/docker/files  before installing xwiki  
#  
# vi /home/teacher/docker/files/init.sql  
# grant all privileges on *.* to xwiki@'%' identified by 'xwiki'  
#  
# you can modify  /home/teacher/docker/init.sql  but not delete it.  
#  
# Be careful with the tab, the indentation is 4 characters.  
#  
name: xwiki_1  ## change  n of xwiki_n  
services:  
    xwiki:  
        cpu_shares: 90  
        command: []  
        container_name: cnt_xki_wb_1  ## change  n  of cnt_xki_wb_n  
        depends_on:  
            xwikidb:  
                condition: service_started  
                restart: true  
                required: true  
            deploy:  
                resources:  
                    limits:  
                        memory: 4096M  
        environment:  
            - DB_USER=xwiki  
            - DB_PASSWORD=xwiki  
            - DB_DATABASE=xwiki  
            - DB_HOST=cnt_xki_db_1  
            - JAVA_OPTS=-Xmx2048m  
        hostname: cnt_xki_wb_1  ## change n to cnt_xki_wb_n  
        image: xwiki:stable-mariadb-tomcat  
        links:  
            - xwikidb:mariadb  
        ports:  
            - target: 8080  
              published: '8081'  ## change  n of 808n  
              protocol: tcp  
        restart: always  
        volumes:  
            - /var/lib/docker/volumes/vol_xki_wb_1/_data:/usr/local/xwiki # create volume from portainer and change  n of vol_xki_wb_n  
        user: 0:0 ## root gid ., as requested for deployment  
        devices: []  
        cap_add: []  
        network_mode: net_xki_1 # create network  from portainer and change  n of net_xki_1  
        privileged: false  
    xwikidb:  
        cpu_shares: 90  
        container_name: cnt_xki_db_1  ## change  n  of cnt_xki_db_n  
        command:  
            - '--character-set-server=utf8mb4'  
            - '--collation-server=utf8mb4_bin'  
            - '--explicit-defaults-for-timestamp=1'  
        deploy:  
            resources:  
                limits:  
                    memory: 4096M  
        environment:  
            - MYSQL_ROOT_PASSWORD=xwiki  
            - MYSQL_USER=xwiki  
            - MYSQL_PASSWORD=xwiki  
            - MYSQL_DATABASE=xwiki  
        hostname: cnt_xki_db_1 ## change  n of cnt_xki_db_n  
        image: mariadb:latest  
        ports:  
            - target: 3306  
              published: '33771'  ## change  n to  3377n  
              protocol: tcp  
        restart: always  
        volumes:  
            - /var/lib/docker/volumes/vol_xki_db_1/_data:/var/lib/mysql  ## create volume from portainer and change  n of vol_xki_db_n  
            - /home/teacher/docker/files:/docker-entrypoint-initdb.d  # In this example, your username is teacher  
        user: 2002:2002  ## mysql-dock  
        devices: []  
        cap_add: []  
        network_mode: net_xki_1  # create network  from portainer and change  n of net_xki_1  
        privileged: false  

Information.
If you want to change your xwiki instance in 2,
edit this file and replace _1 by _2.
Then replace the port 8081 by 8082
and 33771 by 33772.

Xwiki needs to give the 'grant all Privileges' authorizations to the xwiki user to create new schemas.
mkdir -p /home/teacher/docker/files
vi /home/teacher/docker/files/init.sql

grant all privileges on *.* to xwiki@'%' identified by 'xwiki'  

you can modify /home/teacher/docker/files/init.sql but not delete it.

Installation.

docker compose -f /home/teacher/xwiki/instance_xwiki_1.yaml up

As soon as the line appears Office process died with exit code 81
you stop the containers with Ctrl + C.

Otherwise, after waiting 3 minutes ,you stop the containers with Ctrl + C.

7.4 Attach volumes with containers.

On portainer, by default the volumes are marked Unused.

Open Portainer.
http://192.168.60.55:9000

Click on Environments Local.

Select Container cnt_xki_wb_1.
Click on cnt_xki_wb_1.
Click Duplicate/Edit.
Advanced container settings.
Click on Volumes.
Volumes mapping.
Choose container /usr/local/xwiki.
Click on Volume.
Select a Volume.
Choose vol_xki_wb_1 - local.
Click on Deploy the container.
Click on Replace.

Select containers cnt_xki_db_1.
Click on cnt_xki_db_1.
Click Duplicate/Edit.
Advanced container settings.
Click on Volumes.
Volumes mapping.
Choose container /var/lib/mysql.
Click on Volume.
Select a Volume.
Choose vol_xki_db_1 - local.
Click on Deploy the container.
Click on Replace.

7.5 Open Xwiki.

7.5.1 Firewall.

Find your interface for network net_xki_1.
The gateway is displayed in Portainer Networks.
Example:
The net_xki_1 gateway is 172.18.0.1/16.
Network interface is net_xki_1.

ifconfig

net_xki_1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  
        inet 172.18.0.1  netmask 255.255.0.0  broadcast 172.18.255.255  
        ether 02:42:6a:71:3d:51  txqueuelen 0  (Ethernet)  
        RX packets 10742  bytes 23229052 (22.1 MiB)  
        RX errors 0  dropped 0  overruns 0  frame 0  
        TX packets 12571  bytes 5854522 (5.5 MiB)  
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0  

Add rules on firewall.
iptables -t nat -A POSTROUTING ! -o net_xki_1 -s 172.18.0.0/16 -j MASQUERADE
ufw route allow in on net_xki_1 out on eth0 to any from any
ufw allow in from any to any port 8081

The postrouting iptable rule disappears after restarting the server.
The solution is to add the rule in crontab.
Add postrouting iptable in /opt/docker/postrouting_sh.

vi /opt/docker/postrouting_sh

iptables -t nat -A POSTROUTING ! -o net_xki_1  -s 172.18.0.0/16 -j MASQUERADE  

Don't forget to delete line if you no longer use this iptable rule.

Information:
To delete an iptable postrouting rule without reboot.
Postrouting line number.
iptables --list -v --line-numbers -t nat
Remove rule ( 1 is the line number).
iptables -t nat -D POSTROUTING 1

7.5.2 First access Xwiki.

http://192.168.60.55:8081.

Loading Xwiki 11% up to 50%.
First page: Distribution Wizard Continue.
Step 1 - Admin user.
FIRST NAME:admin.
LAST NAME:xwiki.
USERNAME:adminxwiki.
PASSWORD and CONFIRM PASSWORD:as you want.
EMAIL ADDRESS:as you want.
Register and login.
Step 1 - Admin user:You are connected with user admin xwiki.
Continue.
Step 2 - Flavor.
Press the F5 key to update the page.
Step 2 - Flavor.
Click on gray color XWiki Standard Flavor.
Install this flavor.
Install.
The installation takes a long time.
Continue.
Wait a little time.
Step 5 - Report.
Continue.
Wait a little time.
Welcome to your Wiki.

To change the localization.
Click on the Icon Drawer on the top right corner.
Select Administer Wiki.
Select Content.
Select Localization.
Change DEFAULT LANGUAGE and TIMEZONE.
Save.

The xwiki is ready.