I am relatively new to Docker but found it to be of great help. It virtualises software installation and makes installation of dependencies just a matter of downloading files. Subsequently running the programs is a very easy task & as simple as just launching a container and start working. I have experimented with data-science programs like R, Julia & Python and also with MOODLE, Drupal etc.
Here is a good primer for installing docker on Ubuntu - https://docs.docker.com/engine/install/ubuntu/
I prefer this method rather than installing docker as a snap package as it also helps in installing various dependencies and later runs smoothly.
For running multiple containers together I find docker-compose an indispensable tool. Here is a good site for information about docker-compose though I prefer installing docker compose like sudo apt install docker-compose on Ubuntu as there are no dependencies required and it is less complicated than the method given on the website.
Updated on 24th July 2020
Installing and running multiple web development software
Here I will show how one can run instances of Drupal, MOODLE & Opencart simultaneously and then use them for development. It is also hosted on github from where one can directly pull these and run the codes.
For this purpose ensure that the docker-compose files are transferred into three different directories. The reason behind this is that when one runs the command docker-compose up -d a bridge network is created separately for each of the programs and each can be independently accessed using the bridge IP address created by the program. I copied the three docker-compose.yml files into drupal, moodle, opencart directories respectively.
One can copy the below mentioned code (applicable for running on Ubuntu 20.04) to three separate files named docker-compose.yml files using simple text editor. The reason behind is that the default command docker-compose up -d assumes that it is being invoked to execute contents of docker-compose.yml file. it is possible to run yml files with other names also using (if the file name is test_drupal.yml) docker-compose -f test_drupal.yml up -d .
For Drupal (updated on 24th July 2020)
docker-compose.yml file contents will be
version: '2'
services:
mariadb:
image: 'docker.io/bitnami/mariadb:10.3-debian-10'
environment:
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=bn_drupal
- MARIADB_DATABASE=bitnami_drupal
volumes:
- 'mariadb_data:/bitnami'
drupal:
image: 'docker.io/bitnami/drupal:9-debian-10'
environment:
- MARIADB_HOST=mariadb
- MARIADB_PORT_NUMBER=3306
- DRUPAL_DATABASE_USER=bn_drupal
- DRUPAL_DATABASE_NAME=bitnami_drupal
- ALLOW_EMPTY_PASSWORD=yes
ports:
- '8081:8080'
- '8441:8443'
volumes:
- 'drupal_data:/bitnami'
depends_on:
- mariadb
volumes:
mariadb_data:
driver: local
drupal_data:
driver: local
It should be noted that 8081 & 8441 are ports which have been arbitrary chosen & can be anything valid. When when finds the IP address using docker network inspect drupal_default the webpage can be accessed using 172.20.0.1:8081 as the IP address of drupal_default in my case was 172.20.0.1. In case the program is being run on Ubuntu 18.04 just replace 8080 with 80 & 8443 with 443 above. I have already tested it and find it strange why one need to make these changes. It appears the tcp port defaults have been changed due to some reason.
For Moodle (updated on 24th July 2020)
docker-compose.yml file contents will be
version: '2'
services:
mariadb:
image: 'docker.io/bitnami/mariadb:10.3-debian-10'
container_name: db_moodle
environment:
- MARIADB_USER=bn_moodle
- MARIADB_DATABASE=bitnami_moodle
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- 'mariadb_data:/bitnami'
moodle:
image: 'docker.io/bitnami/moodle:3-debian-10'
container_name: moodle
environment:
- MARIADB_HOST=db_moodle
- MARIADB_PORT_NUMBER=3306
- MOODLE_DATABASE_USER=bn_moodle
- MOODLE_DATABASE_NAME=bitnami_moodle
- ALLOW_EMPTY_PASSWORD=yes
ports:
- '8082:8080'
- '8442:8443'
volumes:
- 'moodle_data:/bitnami'
depends_on:
- mariadb
volumes:
mariadb_data:
driver: local
moodle_data:
driver: local
It should be noted that 8082 & 8442 are ports which have been arbitrary chosen & can be anything valid. When when finds the IP address using docker network inspect moodle_default the webpage can be accessed using 172.24.0.1:8082 as the IP address of moodle_default in my case was 172.24.0.1. In case the program is being run on Ubuntu 18.04 just replace 8080 with 80 & 8443 with 443 above. I have already tested it and find it strange why one need to make these changes. It appears the tcp port defaults have been changed due to some reason.
For Opencart (updated on 24th July 2020)
docker-compose.yml file contents will be
version: '2'
services:
mariadb:
image: 'docker.io/bitnami/mariadb:10.3-debian-10'
environment:
- MARIADB_USER=bn_opencart
- MARIADB_DATABASE=bitnami_opencart
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- 'mariadb_data:/bitnami'
opencart:
image: 'docker.io/bitnami/opencart:3.0.3-3'
environment:
- MARIADB_HOST=mariadb
- MARIADB_PORT_NUMBER=3306
- OPENCART_DATABASE_USER=bn_opencart
- OPENCART_DATABASE_NAME=bitnami_opencart
- OPENCART_HOST=localhost
- ALLOW_EMPTY_PASSWORD=yes
ports:
- '80:80'
- '443:443'
- '587:587'
expose:
- '80'
- '587'
- '443'
volumes:
- 'opencart_data:/bitnami'
depends_on:
- mariadb
volumes:
mariadb_data:
driver: local
opencart_data:
driver: local
When when finds the IP address using docker network inspect opencart_default the webpage can be accessed using 172.18.0.1:80 as the IP address of opencart_default in my case was 172.18.0.1 . Interestingly this same code runs properly on Ubuntu 18.04 system.
For running Drupal and Moodle one should run docker-compose up rather than docker-compose up -d as the installation takes time and one will be able to see steps through which the program goes while completing the execution.
In this manner one can run all the three mentioned above simultaneously on a local computer.