109Environment - amagerard/Docker GitHub Wiki
Docker/Home
RedHat10/Docker.
| 1- Docker | 2- Firewall | 3- Portainer | 4- Drupal | 5- Joomla |
|---|---|---|---|---|
| 6- Wordpress | 7- Xwiki | 8- Mediawiki | 9- Environment | |
| Casaos | Zimaos |
9. Environment.
9.1 Create a Yaml script for multiple instances.
Example Drupal instance 1.
You need them all in the same directory.
- .env file.
- instance_drupal.yaml file.
Contents of the .env file.
vi .env
My_instance=1
Edit the instance_drupal_1.yaml. Chapter 4.3 Install Drupal with a yaml script
Replace _1 by _${My_instance}.
Then replace the port 8081 by 808${My_instance}
and 33771 by 3377${My_instance}.
Contents of the instance_drupal.yaml file.
vi instance_drupal.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
# you must create network net_dpl_1 from portainer before installing drupal.
# you must create volume vol_dpl_wb_1 from portainer before installing drupal.
# you must create volume vol_dpl_db_1 from portainer before installing drupal.
#
# Be careful with the tab, the indentation is 4 characters.
#
name: drupal_${My_instance} ## change n of drupal_n
services:
drupal:
cpu_shares: 90
command: []
container_name: cnt_dpl_wb_${My_instance} ## change n of cnt_dpl_wb_n
depends_on:
drupaldb:
condition: service_started
restart: true
required: true
deploy:
resources:
limits:
memory: 2048M
environment:
- DRUPAL_DB_HOST=cnt_dpl_db_${My_instance} ## change n of cnt_dpl_db_n
- DRUPAL_DB_PASSWORD=641fqAB4d ## Change password if you want
hostname: cnt_dpl_wb_${My_instance} ## change n of cnt_dpl_wb_n
image: drupal:latest
links:
- drupaldb:mariadb
ports:
- target: 80
published: '808${My_instance}' ## change n of published : 808n
protocol: tcp
restart: always
volumes:
- /var/lib/docker/volumes/vol_dpl_wb_${My_instance}/_data:/var/www/html # create volume from portainer and change n of vol_dpl_wb_n
user: 2001:2001 ## www-dock (uid:gid)
devices: []
cap_add: []
network_mode: net_dpl_${My_instance} # create with portainer, change n of net_dpl_n
privileged: false
drupaldb:
cpu_shares: 90
command: []
container_name: cnt_dpl_db_${My_instance} ## change n of cnt_dpl_db_n
deploy:
resources:
limits:
memory: 2048M
environment:
- MYSQL_ROOT_PASSWORD=641fqAB4d # it is the same password DRUPAL_DB_PASSWORD
hostname: cnt_dpl_db_${My_instance} ## change n of cnt_dpl_db_n
image: mariadb:latest
ports:
- target: 3306
published: '3377${My_instance}' ## change n of 3377n
protocol: tcp
restart: always
volumes:
- /var/lib/docker/volumes/vol_dpl_db_${My_instance}/_data:/var/lib/mysql ## create volume from portainer and change n of vol_dpl_db_n
user: 2002:2002 ## mysql-dock (uid:gid)
devices: []
cap_add: []
network_mode: net_dpl_${My_instance} # create network from portainer and change n of net_dpl_1
privileged: false
Installation.
docker compose -f /home/teacher/drupal/instance_drupal.yaml up
Crtl+C to stop.
Information.
If you want to change your drupal instance in 2,
Edit .env file.
Replace 1 by 2
The .env file for Wordpress is :
My_instance=1
My_network=172.18.0.1