205Wordpress - amagerard/Docker GitHub Wiki

Docker/Home

Ubuntu/Casaos.

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

5. Wordpress.

Wordpress is a Content Management System.
It is possible to create, manage and easily modify a website.

This procedure is based on this example.

Ubuntu ip : 192.168.60.8/24
Casaos version: v0.4.15
Your username: teacher
Your home directory:/home/teacher

5.1 Create Network and Volumes with Portainer.

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

Click on Environments Local.

5.1.1 Each Wordpress instance has its container.

  • cnt_wps_wb_number.
  • cnt_wps_db_number.
    Containers will be created from Casaos graphical interface.

5.1.2 Each Wordpress instance has its network.

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

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

5.1.3 Each Wordpress instance has its volume.

  • vol_wps_wb_number
  • vol_wps_db_number
    Create these volumes.
Select Volumes.  
Add volume.  
Name: vol_wps_wb_1  
Create the volume.  
Add the volume.  
Name: vol_wps_db_1  
Create the volume.  

5.2 Install Wordpress with a yaml script.

Copy this script in notepad, kate, gedit or another text editor
and save with a name that has a yaml extension.

# 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.8  
# you must create network net_wps_1    from portainer before installing wordpress.  
# you must create volume vol_wps_wb_1  from portainer before installing wordpress.  
# you must create volume vol_wps_db_1  from portainer before installing wordpress.  
#  
# Be careful with the tab, the indentation is 4 characters.  
#  
name: wordpress_1  ## change  n of wordpress_n  
services:  
    wordpress:  
        cpu_shares: 90  
        command: []  
        container_name: cnt_wps_wb_1  ## change  n  of cnt_wps_wb_n  
        depends_on:  
            wordpressdb:  
                condition: service_started  
                restart: true  
                required: true  
        deploy:  
            resources:  
                limits:  
                    memory: 2048M  
        environment:  
            - WORDPRESS_DB_HOST=172.18.0.1:33771  ##<ip gateway network net_wps_1>:port published mariadb  
            - WORDPRESS_DB_NAME=wordpress  
            - WORDPRESS_DB_USER=wordpress  
            - WORDPRESS_DB_PASSWORD=password  ## as you want  
        hostname: cnt_wps_wb_1  ## change n to cnt_wps_wb_n  
        image: wordpress:latest  
        links:  
            - wordpressdb:mariadb  
        ports:  
            - target: 80  
              published: '8081'  ## change  n of 808n  
              protocol: tcp  
        restart: always  
        volumes:  
            - /var/lib/docker/volumes/vol_wps_wb_1/_data:/var/www/html # create volume from portainer and change  n of vol_wps_wb_n  
        devices: []  
        cap_add: []  
        network_mode: net_wps_1 # create network  from portainer and change  n of net_wps_n  
        privileged: false  
    wordpressdb:  
        cpu_shares: 90  
        command: []  
        container_name: cnt_wps_db_1  ## change  n  of  cnt_wps_db_n  
        deploy:  
            resources:  
                limits:  
                    memory: 2048M  
        environment:  
            - MYSQL_ROOT_PASSWORD=password ## it is the same MYSQL_PASSWORD  and WORDPRESS_DB_PASSWORD  
            - MYSQL_DATABASE=wordpress  
            - MYSQL_USER=wordpress  
            - MYSQL_PASSWORD=password  ## it is the same MYSQL_PASSWORD  and WORDPRESS_DB_PASSWORD  
  
        hostname: cnt_wps_db_1 ## change  n of cnt_wps_db_n  
        image: mariadb:latest  
        ports:  
            - target: 3306  
              published: '33771'  ## change  n to  3377n  
              protocol: tcp  
        restart: always  
        volumes:  
            - /var/lib/docker/volumes/vol_wps_db_1/_data:/var/lib/mysql  ## create volume from portainer and change  n of vol_wps_db_n  
        devices: []  
        cap_add: []  
        network_mode: net_wps_1  # create network  from portainer and change  n of net_wps_1  
        privileged: false  
  
x-casaos:  
    author: self  
    category: self  
    hostname: 192.168.60.8  ## change IP  
    icon: https://s.w.org/style/images/about/WordPress-logotype-wmark-white.png  # check if existe  
    index: /  
    is_uncontrolled: false  
    port_map: '8081' ## change  n of  808n  
    scheme: http  
    store_app_id: wordpress_1  ## change  n of  wordpress_n  
    title:  
        custom: wordpress_1 ## change  n  of wordpress_n  

Open casaos .
http://192.168.60.8.

Click on the "+" which is located in the middle right of the browser web page.
Install a customized app.
Click on right top who name "import".
Import.
Click on Drag your Docker Compose here or click to upload.
Search your script yaml.
Submit.
OK and OK.
Install.

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

5.3 Attach volumes with containers.

On portainer, by default the volumes are marked Unused.
This is a problem for Wordpress.

Launch Portainer.
http://192.168.60.8:9000

Click on Environments Local.

Select Container cnt_wps_wb_1.
Stop cnt_wps_wb_1.
Click on cnt_wps_wb_1.
Click on Duplicate/Edit.
Advanced container settings.
Click on Volumes.
Volumes mapping.
Choose container /var/www/html.
Click on Volume.
Select a Volume.
Choose vol_wps_wb_1 - local.
Click on Deploy the container.
Click on Replace.

Select Container cnt_wps_db_1.
Stop cnt_wps_db_1.
Click on cnt_wps_db_1.
Click on Duplicate/Edit .
Advanced container settings.
Click on Volumes.
Volumes mapping.
Choose container /val/lib/mysql.
Click on Volume.
Select a Volume.
Choose vol_wps_db_1 - local.
Click on Deploy the container.
Click on Replace.

5.4 First access Wordpress.

http://192.168.60.8:8081

Select language : English.
Continue.
Site Title : mybeautifulweb.
Username: as you want.
Password: as you want.
Confirm use a weak password : as you want.
Your Email: as you want.
Search engine visibility : as you want.
Install WordPress.
Login.
Username: your username.
Password: your password.

Wordpress is ready.

To return to the administrator page.
http://192.168.60.8:8081/wp-admin