How to install pmm2 server through docker on the custom data directory in the Centos Linux

Can somebody help me the pmm2 server installation through docker, instated of default directory I want to install the pmm2 server in the different data directory.

For Example:
Below is my directory structure and we have mounted new directory, i.e is /db/data

  1. / – root directory
  2. /tmp
  3. /db/data

So, I don’t want to install docker in the default directory, I want to install in the /db/data directory.
Can somebody help me on this?

instated of default directory

The “default directory” for PMM server is a docker volume, located in /var/lib/docker/volumes

Is PMM the only thing you are running in docker? If so, you can change the global location where docker stores volumes by setting this parameter in /etc/docker/daemon.json. Be sure to restart docker daemon.

{ "data-root": "/db/data" }

If you only want PMM to store data in your custom location, simply bind-mount the path into the container when launching it. Example:

docker run -d -v /db/data:/srv -p 443:443 percona/pmm-server:2

Hi Matthewb,

Thanks for the quick help.
I tried to change the directory in the /etc/docker/daemon.json, but I am getting the below error.

Nov 20 04:14:39 dockerd-current[87267]: unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives don’t match any configuration option: data-root

1 Like

What is inside the /etc/docker/daemon.json file? The example I gave above is taken directly from the official docker documentation.

  1. Remove daemon.json
  2. Start docker, make sure clean start up
  3. Stop docker
  4. rsync -axPS /var/lib/docker/ /db/data
  5. Put daemon.json back with data-root path
  6. Make sure /db/data is owned/grouped by docker
  7. Start docker

Hi @matthewb

Thanks for the help, after searching some blogs and finally its working fine without doing the above steps.
I found the below solution for my case.

I have changed from “data-root” to “graph” is working fine directly. No need to copy files from /var/lib/docker/ to /db/data directory, so after installing the docker the I have modified the below file and started the docker service, after that its installed the all the files to /db/data directory without copying from the default /var/lib/docker/ directory.

Docker version 1.13.1
cat /etc/docker/daemon.json
“graph”: “/db/data”

Thank you so much @matthewb for the help.

Final Thing:
**If I want to upgrade PMM2 server from 2.23 to 2.24,so I should to stop the pmm2-agent then I have to upgrade the pmm2-server


Directly Can I upgrade the pmm2-server without stopping the pmm2-agent and after upgrading the PMM2 server then I have to upgrade the pmm-agent .**

Can you please suggest me the steps high level to upgrade the pmm2 server and agent?

1 Like

Interesting. Here is the official documentation stating that you must use data-root in the json file. Configure and troubleshoot the Docker daemon | Docker Documentation

Oh, you are running a VERY OLD VERSION of docker! Like VERY VERY old! Current version is Version: 20.10.8

1 Like

Yes @matthewb , let me try the new version.
Thanks for the help.

1 Like

Hi @matthewb

I have installed the latest Docker and now I am able to start the docker in side /db/data directory.

I have changed the /etc/docker/daemon.json file and added the below details.
{ “data-root”: “/db/data” }

But How do I create the docker with the below command?

  1. docker create --volume /srv --name pmm-data percona/pmm-server:2 /bin/true
  2. docker run --detach --restart always --publish 80:80 --publish 443:443 --volumes-from pmm-data --name pmm-server percona/pmm-server:2

Are the above commands are fine any changes required, I have a doubt on the --volume and --volumes-from parameter’s, am I missing something here?

1 Like

Docker is a daemon running in the background of your OS. Docker is responsible for launching containers which have PMM (and other software) running inside the container. You should go watch a Docker 101 video if you are unfamiliar with these contepts.

The commands you pasted (1, & 2) are the exact correct commands. #1 creates a container-volume so that you don’t lose data on upgrades. #2 creates the PMM server container and runs it in the background (–detach) using the volume you created in #1 for data storage.

Since you moved Docker’s datadir to /db/data, any docker volumes created will be stored there.

1 Like

Hi @matthewb

Thanks for the help.
If I want to do pmm2 server upgrade, then I thought, I may loose data, now I am cleared with your suggestions.