Where the open source database community meets: Use code PERCONA75 and secure your spot for Percona Live.  Register

Using Different Mount Points on PMM Docker Deployments

March 20, 2018
Author
Agustín Gallego
Share this Post:

Mount Points on PMM DockerIn this blog post, we’ll see how to use different mount points on PMM Docker deployments (Percona Monitoring and Management). This is useful if you want to use other mount points for the different directories, or even if you want to use a custom path that is not bound to Docker’s volumes directory (which is /var/lib/docker/volumes/ by default) within the same mount point.

There are two ways in which you can achieve this:

    • using symlinks after the pmm-data container is created
    • modifying the docker create command to use different directories

In the following examples, /pmm/ is used as the new base directory. One can, of course, choose different directories for each if needed. Also, remember to be aware of any SELinux or AppArmor policies you may have in place.

Using symlinks

For this, we need to follow these steps:

    1. Create the needed directories
    1. Create the pmm-data container
    1. Move contents from default Docker paths to the desired paths
    1. Create symlinks that point to the moved directories

Let’s see this with some commands and outputs. In this example, we will use /pmm/ as if it were the new mount point:

After this, we can start the pmm-server container (see below).

Modifying the docker create command

For this, we need to follow these other steps:

    1. Create the needed directories
    1. Create a temporary pmm-data container
    1. Copy its contents to the new locations, and delete it (the temporary container)
    1. Create the permanent pmm-data container with the modified paths (-v arguments)
    1. Fix ownership of files in the copied directories (to avoid errors when starting the pmm-server container later on)

Let’s see this in practical terms again, assuming we want to use the /pmm/ mount point.

After this, we can start the pmm-server container (see below).

Running pmm-server container

After following either of the steps mentioned above, we can run the pmm-server container with the exact same commands as shown in the online documentation:

And that’s it! Now you should have custom mount points on PMM docker deployment.

0 0 votes
Article Rating
Subscribe
Notify of
guest

8 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Janis Puris
Janis Puris
7 years ago

Step #3 is not correct with recent docker versions

The docker paths need to have “/.” at the end as per https://docs.docker.com/engine/reference/commandline/cp/
If this is not done, the cp command will nest the directories in destination path and mysql will fail to start (among to start with).

Change following

shell> docker cp pmm-data-temporary:/opt/prometheus/data /pmm/opt/prometheus/data
shell> docker cp pmm-data-temporary:/opt/consul-data /pmm/opt/consul-data
shell> docker cp pmm-data-temporary:/var/lib/mysql /pmm/var/lib/mysql
shell> docker cp pmm-data-temporary:/var/lib/grafana /pmm/var/lib/grafana
shell> docker rm -v pmm-data-temporary

to

shell> docker cp pmm-data-temporary:/opt/prometheus/data/. /pmm/opt/prometheus/data
shell> docker cp pmm-data-temporary:/opt/consul-data/. /pmm/opt/consul-data
shell> docker cp pmm-data-temporary:/var/lib/mysql/. /pmm/var/lib/mysql
shell> docker cp pmm-data-temporary:/var/lib/grafana/. /pmm/var/lib/grafana
shell> docker rm -v pmm-data-temporary

Tanuj
Tanuj
6 years ago

We get permission denied error when we run step 5
chown: cannot read directory ‘/opt/prometheus/data’: Permission denied
chown: cannot read directory ‘/opt/consul-data’: Permission denied
chown: cannot read directory ‘/var/lib/grafana’: Permission denied
chown: cannot read directory ‘/var/lib/mysql’: Permission denied

Fernando Mattera
Fernando Mattera
6 years ago

Excelent post!

I did this a year ago, and still working

Jose Manuel Vera
Jose Manuel Vera
6 years ago

This procedure leads to Prometheus template error on CentOs 7

molguram vinay
molguram vinay
6 years ago

Also a workaround. To change the docker default configuration and make it use the Disk/Partition that we want to.

For the above example, If we want to use the /pmm/ .

1. Stop docker service:
systemctl stop docker.service

2. Override defaults(which is /var/lib/docker/volumes/) to use /pmm.

Add in /etc/systemd/system/docker.service.d/override.conf

[Service]
ExecStart=
ExecStart=-/usr/bin/dockerd -H fd:// -g /pmm/docker –containerd=/run/containerd/containerd.sock

3. Start docker service:
systemctl status docker.service

systemctl status docker.service

Now follow the same steps to Install and configure: https://www.percona.com/doc/percona-monitoring-and-management/2.x/install/docker-setting-up.html

And then, you will have docker using the /pmm mount.

Far
Enough.

Said no pioneer ever.
MySQL, PostgreSQL, InnoDB, MariaDB, MongoDB and Kubernetes are trademarks for their respective owners.
© 2026 Percona All Rights Reserved