
Recently, the
article Iron_Butterfly was published , where, among other things, it tells how you can run the most powerful search engine ElasticSearch inside the Docker container. I want to continue this vector and tell you what other tasks can be solved with the help of Docker containers using Plesk and the Docker extension.
Short plan
In this article, we will look at how using the Docker extension can solve tasks that are hard or even impossible to solve with Plesk without Docker containers. This list of tasks is based on the popular questions of our users; as users, we will consider hosting owners, web application developers, WordPress admins.
')
Tasks:
- Simultaneous use of different versions of databases;
- Expanding Memcached for WordPress;
- Using your own cloud storage Nextcloud;
- Run your own application on Go. Running your own git repository;
- Testing new versions of Plesk without interfering with the combat server.
I want to clarify that all the examples in the article are made using the free version of the Docker extension; The paid version allows you to manage Docker service on remote servers.
Instead of introducing
Short glossary of terms used- Docker is an automation software for deploying and managing applications in a virtualization environment at the operating system level.
- Docker extension (Docker extension) is an extension that is installed inside the Plesk control panel to extend the functionality of the panel itself.
Before we go over to specific examples, let's take a quick look at the limitations in the current version and prepare Plesk to work with containers.
Known issues and limitations
- The ports specified in the Dockerfile are set to default by default. For some containers, this behavior is undesirable. Always check and close access to containers from the outside, if access is not required;
- It is possible to close access to the container from the outside by means of a system firewall. In cloud environments, these ports can be closed by default by the cloud firewall and / or security group. Containers in this case will be available from localhost;
- All volumes are connected with read-write permissions. You cannot set read only rights;
- You cannot use docker-compose and its configuration files.
Deploy environment. Installing Docker Extensions
0. Obtain a valid certificate using Let's Encrypt (this is an optional step, I will remove the self-signed certificate warning);
1. Select Extensions in the left menu;
2. Find a Docker;
3. Click “Install”;
4. Wait until the installation process is complete;
5. Go to the extension. Is done.
Get a valid certificate using Let's Encrypt (optional)Select Extensions in the left menu.Find a DockerClick “Install”Wait for the installation process to complete.Go to the extension. Is doneTasks
Hosting provider
- Clients on our forum periodically ask how to upgrade MySQL / MariaDB to the latest supported version of Plesk.
- Sometimes questions arise about how to use a web application that has a MySQL 5.7 or MariaDB 10.2 database specified in its minimum requirements, or if the client wants to use the latest version of the database, since it is better in performance tests.
- The client wants full control over the MySQL server, not the database.
Soon we will look at how to solve the listed tasks, but before that we will see what tasks the web developer can face.
Web developer
Let's imagine that you are a web application developer. Today you are starting to develop a new web application that will save all the data in a SQL database. What SQL database will you use? Perhaps you would prefer to write a web application so that it works with all popular databases, since This will help to attract more customers. So which databases do you know?
- Officially supported in Plesk (this is not a complete list, just as an example)
- MySQL 5.5 / 5.6 / 5.7
- MariaDB 10.0 / 10.1
- PosgreSQL 9.5
- Not supported in Plesk
- MySQL 8.0
- MariaDB 10.2
- PostgreSQL 9.6
- Something else?
- Microsoft SQL Server on Linux
Well, your application is ready, but now you need to test it with all these databases. Let's look at how this task can be solved with the help of Plesk, Docker and Docker extensions.
Install containers with all necessary databases
We will use the official Docker Hub containers:
Consider the installation of one of the containers, let's say MariaDB 10.0:- Find the available containers with MariaDB, select the required version;
- Wait until the installation is complete;
- Configure the necessary parameters:
- Turn on autoload;
- Specify static port mapping;
- Add volume mapping so that data is stored outside the container;
- Set the environment variable with the password for root.
- Create a container and wait for it to start.
Repeat the steps to create containers for MariaDB 10.1 / 10.2, MySQL 5.5 / 5.6 / 5.7 / 8.0, PostgreSQL 9.5 / 9.6.
Find the available containers with MariaDB, select the version you want.Wait for the installation to complete.Set the necessary parametersCreate a container and wait for it to start.Repeat container creation stepsUsing Created Databases in Plesk
Below are two options for the possible use of the created databases:
- Add the created databases to Plesk so that customers can use them in their subscriptions.
- If the database is not supported by Plesk, then you can use it by connecting directly (this is relevant, for example, for MySQL 8.0)
A few screenshots that show how the result looks like on the configured system.
Add DB to PleskThe resulting resulting DB list in PleskHow it all looks inside the OSWordPress Admin
Another task that may be relevant for site owners with Wordpress, and the solution of which I would like to consider in this article.
- Install the Memcached daemon to increase the speed of WordPress and reduce the load on the CPU.
- For security reasons, you should disable access to Memcached from anywhere except WordPress.
- In this example, Plesk is deployed in Google Cloud, so I am protected by the cloud platform's firewall.
Steps:- Check your firewall settings; you should block external connections to memcached;
- Find and install the container with Memcached;
- Enable autorun and configure port mapping;
- Run the container;
- Check that everything works.
Check your firewall settings, you must block external connections to memcached (individually)Find and install a container with memcachedEnable autorun and configure port mappingRun the containerCheck that everything works.Organization
A task that may be relevant for small organizations: you want to have your own resource for file sharing based on Nextcloud. This problem can also be easily solved.
Own Nextcloud in Plesk with Docker?
Steps:- Find and install the container with Nextcloud;
- Please note that the volume mapping is not configured; This is done deliberately, because inside Dockerfile for Nextcloud, use unnamed docker volume.
- Wait until it starts;
- Configure proxy rules for Docker in “Websites & Domains”;
- Open the Nextcloud web interface and set the name and password for the administrator;
- Is done. You can use Nextcloud.
Find and install the container with NextcloudWait until it starts.Configure proxy rules for Docker in “Websites & Domains”Open the web interface of Nextcloud, set the name and password for the administratorIs done. You can use NextcloudGo developer
Currently, Plesk does not have extensions that allow you to work with Go, but you can write an application on Go and run it under Plesk in a Docker container. I do not know how to write on Go, so for clarity, I will take the finished product written on Go and show you how to run your own git-service in Plesk.
Find a container with GogsSet up a container with GogsRun the container with GogsSpecify the initial settings for the Gogs itselfIs done. Own git service is up and runningCreate the first repository. Let's call it ... HelloWorldTesting new versions of Plesk!
Let's install Plesk as a Docker container in Plesk with the Docker extension! Immediately answer the question "Why?":
- You can test your own planned changes in an isolated environment, regardless of the combat version of the site and only then apply them to the public version of the site.
- You can deploy Plesk Preview, see the new functionality, if necessary, check in advance that the websites are ready to be updated in the future.
Find a Plesk ContainerCustomize Plesk ContainerLaunch the Plesk container. Is done. Can checkConclusion
Instead of a conclusion, I propose to discuss in the comments which public containers with Docker Hub you regularly use in your daily work, or vice versa, why did you refuse to use public containers in your tasks.