Docker is a platform for distributed applications for developers and system administrators that allows running applications in containers. It enables you to use specific software, such as Redis or MongoDB, or a specific version of software, which might not be supported by your operating system or might need compiling.
Docker is available as a Plesk extension. Plesk allows you to run and manage containers that are based on specific Docker images, and to use Docker not only on the local host, but also on the specified remote machine.
In Plesk for Windows, you can use Docker installed on a remote machine (see Using Remote Docker further in this section).
Install the Docker extension in Plesk.
To start using it, go to Docker in the left navigation panel.
In the catalog (Docker > Docker Image Catalog), Plesk displays images from https://hub.docker.com/explore. By default, only recommended images are displayed. To view more images, use the search box or filters.
For each application, multiple versions can be available. You can run a specific version by selecting the appropriate tag, as shown below:
To use filters:
The repositories that you can select:
To run a container:
If the image is stored locally, the button appears as Run (local).
Plesk creates a container and prompts you to specify its settings, such as environment variables, and then runs it. You can cancel running by clicking Cancel on the Settings screen. For details about the settings, see Container Settings later on this page.
See the log (Logs) to find out what settings the container needs to run successfully.
Note: If you want to change container settings, you do not need to stop the container: When you save new settings, Plesk recreates the container.
To edit container settings, go to Settings or Details > Settings.
Limiting memory
By default, using RAM in a Docker container is unlimited. To limit using RAM, clear the Unlimited checkbox and enter the limit value in megabytes in the Memory limit field.
Note: CPU and Disk usage cannot be limited for a Docker container at the moment.
Note: Docker containers are administrator-level objects, and are not controlled by subscription-level cgroup limits (CPU, RAM, Disk usage).
Automatic Start
If the option Automatic start after system reboot is not selected, then after system reboot the websites that use this container might be down and you will need to start the container manually.
Port Mapping
By default, Automatic port mapping is turned on and the container's internal port is mapped to a random port on the host system (for example, 32768).
To change the port on the host system, clear the option Automatic port mapping and specify another external port in Manual mapping. If no Manual mapping appears when you clear the check box, it means that the container does not expose ports.
Important: If port mapping is configured, Docker binds to the specified port on all network interfaces of the host system. Usually, this means that the application can be accessed from anywhere. Docker presumes that authentication is carried out by the application itself, but sometimes it is not so (for example, MySQL does not allow anonymous access by default, but redis does).
Plesk cannot determine what service is installed in a specific Docker container, and cannot control access to it. If you need to prohibit access to the application from outside Plesk, do it manually using the firewall on the host system.
Volume Mapping
Docker volumes are directories on your server mounted to a Docker container, so that you have persistent storage that can be accessed from your host system. The data in Docker volumes can be backed up, and, more importantly, it is not deleted when you stop or delete a container.
For more information about data in containers, refer to the Docker documentation.
To add a volume mapping, specify the following:
To map more directories, click Add Mapping.
Setting Environment Variables
Environment variables are used by the application inside a container. You might need to add more variables or edit existing variables. Plesk allows you to add as many variables as required.
pYou can do the following with containers:
Note: If you did not save the data to the mounted volumes (see the Volume Mapping section below), the data will be lost.
In Plesk on CentOS, you can set a memory limit for a container (Settings > Memory limit).
Usually, you need to recreate a container when you want to update the application to a newer version. In fact, you can rebuild a container using any application version available in the catalog, not only a newer one.
Custom settings are preserved during recreation. To preserve data used by the application inside a container, you should specify volume mapping before you recreate a container. Volume mapping enables you to have access to directories used inside a container (see Volume Mapping in container settings).
To recreate a container:
By default, Plesk uses Docker installed as a Plesk component. However, you can use one or more Docker services installed outside of Plesk. Note that you can use only one service at a time. The hostname of the selected server is displayed in the title of Docker Catalog in Plesk.
Important: Managing remote Docker services requires a Plesk license key add-on. Without this add-on, you can only manage the local Docker service, which is running on the Plesk server.
Configuring Remote Services
Configure the remote server that runs Docker as described in the Docker documentation to use it as a remote server in Plesk.
Managing Remote Services
The following steps are applicable to both Plesk for Linux and for Windows.
To start using Docker that runs on a remote host:
The link to Docker will appear in the left navigation panel.
To switch between Docker services:
Alternatively, you can set the server as active while editing its settings.
If you want to create a new image based on the changes that you have made to a container, use the Save as Image command. This takes a snapshot of your container, which appears as a new image in the image catalog. In this way, you can create images with custom settings such as environment variables.
To create an image from one of your containers:
Go to Docker > Details under the container name > Save as Image, and optionally specify:
The created image appears in the image catalog and is marked Local image.
Local images are images that are stored by Docker on a local disk, so there is no need to download them from the Image Catalog.
An image becomes local in the following situations:
If Docker has at least one downloaded version from a group of versions belonging to an image, this image is marked Local image in the catalog. Run (local) means that the latest version was already downloaded. Plesk also shows how many local images exist for a product.
To view local images and remove outdated local images:
Some Docker containers expose ports so that applications in containers could be accessible via those ports.
When you use an application in Docker container on your website, you may find it inconvenient to specify the non-standard port in its URL. To avoid inconvenience, you can set up nginx to proxy requests from domains to that port, so domains can use a standard port (such as 80) and there is no need to explicitly specify the port in URL.
Requirements
After you have mapped the port inside a container manually to some port on your system (for example, 32768), you can set up nginx to proxy requests from domains to that port, so domains can use a standard port on nginx (for example, 80). To make this possible, add a rule for nginx in the domain settings in the following way:
Go to Websites & Domains > the domain > Proxy Rules > Add Rule and specify the following:
Proxy rules are implemented in the web server configuration, e.g., in the website's file nginx.conf
(in /var/www/vhosts/system/$domain/conf/
):
#extension docker begin
location ~ ^/.* {
proxy_pass http://0.0.0.0:9080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#extension docker end
Proxy rules should work fine on servers behind NAT.
Note: Docker containers connected via Proxy Rules to a website are not counted towards the subscription's disk space usage. An exception to this would be when a website directory is mounted to a Docker container as a volume, as in this case all files located in the container will be counted towards the disk space usage of the website.