This blog post will explain how to create a multi-image Docker container. The two images that will be used are mysql and nextcloud. Before deploying a MySQL container, there has to be a volume setup to link to the directory /var/lib/mysql inside the container. Before deploying a nextcloud container, there has to be a volume setup to link to the directory /var/www/html/data inside the container. Also, a password has to be set for the MySQL root user by using the environment variable MYSQL_ROOT_PASSWORD. A docker compose.yaml file displayed below contains all the information needed for a multi-image container.
services:
nextcloud:
image: nextcloud
depends_on:
- mysql
ports:
- 9090:80
volumes:
- nextcloud:/var/www/html/data
mysql:
image: mysql
volumes:
- database:/var/lib/mysql
ports:
- 3060:3060
environment:
MYSQL_ROOT_PASSWORD: 1234
volumes:
database:
nextcloud:
The next step is to use the Docker command line interface to navigate to a directory with a compose.yaml file and input the command listed below.
docker compose up -d
I had to use nextcloud-mysql as the connection string. I figured out the name by using the command below.
docker ps -a
The image below shows how to input the connection string into the Nextcloud configuration screen.