This guide helps you to deploy a MySQL/MariaDB/Percona (StandAlone and MasterSlave) service in a Docker container using the D2C platform. We put them together because the process is the same for all services. It might be helpful for beginners as well as for advanced developers.
A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Containers isolate software from its surroundings, for example, differences between development and staging environments and help reduce conflicts between teams running different software on the same infrastructure.
Please, check out the original Docker post about containers for a better understanding of all the benefits of the technology.
Creating MySQL/MariaDB/Percona service
At first, you need to open or create any project and click “+Create service“. You will see a list of services which can be deployed with D2C:
Let’s go ahead and click on MySQL/MariaDB/Percona bar.
Creating MySQL/MariaDB/Percona service. Service settings
The name should start with a letter and contain up to 16 characters (Latin letters, numbers, hyphen).
Each service has its unique name. Services can communicate with each other by container names (e.g.
kitty-1) or alias-names (e.g.
At this step, you can choose a configuration for a service. For MySQL/MariaDB/Percona, we support StandAlone and MasterSlave configurations. MasterSlave configuration requires to have at least two hosts (two containers will be deployed – one master and one slave).
You can choose a version for your application from a list:
In this field, you can specify a root password for a database. Root password can be changed after deployment.
In this field, you can specify username for a database.
Password for a user of database
Create a name of a database after deploying.
In most of the cases, that is enough for deploying a database. You can now select hosts and create a service. Data services also have advanced settings. We show them below.
Creating MySQL/MariaDB/Percona service. Select hosts
At this image shown selected hosts block for MasterSlave configuration. At first click, you choose a host for the master container and then for slaves. Click once again if you need to change master and slave hosts.
There is an opportunity to change configuration from StandAlone to MasterSlave after deployment, so you can choose what you need for a start and then scale when it needs.
Also, at this step you can create other hosts and choose them even they are not online yet (creating/setting up status). The containers will be deployed when they are ready.
After successful deployment your project should look like:
Creating MySQL/MariaDB/Percona service. Advanced settings
Click “Show advanced settings”.
The first block in this area is Ports.
Access from the Internet is disabled by default. You can enable access from the Internet while creating or editing service. But it is not recommended for security reasons and it is not necessary for communication with services which are running in D2C. Containers are started inside a private network and have dynamically assigned local IP addresses. Apps can reference each other by container name. It does not matter on which host the service is running – all private network intercommunication is transparent for all services in your account.
Persistent data volumes
D2C separates the application itself from its data. Docker volumes are used to store persistent data. Data is stored locally on the hosts.
D2C creates a default config for MariaDB/MySQL/Percona. You can change it using the “Edit” button.
Click on the “Generate new config” button if you need to return to default config.
In this field, you can specify commands for installing global dependencies of your service.
Commands which are executed only once after deploying a service.
In the next article we talk about:
- maintaining data services: creating backups, scaling, checking containers logs and metrics, updating version