Using Different Mount Points on Percona Monitoring and Management 2 Docker Deployments

Percona Monitoring and Management 2 Docker Deployments

Percona Monitoring and Management 2 Docker DeploymentsTwo years ago, we showed how to use a different mount point on Percona Monitoring and Management (PMM) Docker deployments, in case you need to have data stored out of the default Docker paths. We have released PMM version 2 since, and the need for these steps is still current. However, there are a few subtle differences, which prompt for an update.

Previously, we saw how to do this in two ways:

  • using symlinks to point to the new mount point, and
  • modifying the docker create command for the pmm-data container

In this blog, I have decided to show steps for only the former. Modifying the Docker command will work, but it is highly dependent on the version used. If in the future we decide to change how the /srv/ directory is structured (i.e., which users own each subdirectory), the steps used here may not be valid anymore. By using the symlink method, we make sure we are keeping the user ownership intact and can assure the steps will work with future versions.

Note that these steps are to be done before having a running PMM setup (meaning this will replace the PMM server installation steps). If needed, we can show steps on how to move an existing setup to a different mount point in the future, so let us know in the comments section.

Executing the Needed Commands

PMM stores all persistent data in the volume mounted by the pmm-data container (this is why it’s important to never remove or delete the pmm-data container). It uses the /srv/ path internal to the pmm-data container to do this. To avoid Docker using the default paths (typically /var/lib/docker) to store the data, we will let it be created and then move all the files, and create the symlink back to it. We will use /pmm2/ as the new path in our examples. If you intend on using a different one, remember to replace it in the following commands.

There are five easy steps for this procedure (you will need to use an account with enough OS-level privileges for them).

1- Create the needed directory

mkdir -p /pmm2/srv/

Make sure the directory has the read and execute permissions for all users (or use chmod 755 to set this).

2- Create the pmm-data container

docker create \
   -v /srv/ \
   --name pmm-data \
   percona/pmm-server:2 /bin/true

3- Check the mappings for the path to the /srv/ directory:

docker inspect pmm-data | egrep "Source|Destination"

We will need the “source” path, which is the host mapping. As an example, you should get something like the following:

"Source": "/home/docker/volumes/62c580b9332e38c116a133d00e9a56048903f5d4e860bf1572056abec1d73075/_data",
 "Destination": "/srv",

So we create the following variable, to help make the following steps more generic and easy to read:


4- Move all the data in it to the desired mountpoint (remember in this case we are using /pmm2/srv/​ but your case may be different):

mv ${DOCKER_VOLUME_DATA}/* /pmm2/srv/

5- Remove the empty _data directory, and create the symlink back to it:

ln -s /pmm2/srv ${DOCKER_VOLUME_DATA}

Running pmm-server Container

We are now ready to run the final step of the procedure, to create the pmm-server container that will provide the actual services running:

docker run -d \
   -p 80:80 \
   -p 443:443 \
   --volumes-from pmm-data \
   --name pmm-server \
   --restart always \

You are now ready to login to PMM via the web UI, and to start configuring clients!

Removing pmm-data

One last note on this. If at some point you intend on removing all data associated with your custom PMM v2 installation, note that data in the new mount point will not be removed by using docker rm -v pmm-data nor docker volume prune, and you will have to manually delete the files to reclaim the space.

by Agustín via Percona Database Performance Blog