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

**URL:** <https://forums.percona.com/t/how-to-install-pmm2-server-through-docker-on-the-custom-data-directory-in-the-centos-linux/13113>\
**Category:** Percona Monitoring and Management (PMM)\
**Created:** [November 19, 2021, 10:43am UTC](https://forums.percona.com/t/how-to-install-pmm2-server-through-docker-on-the-custom-data-directory-in-the-centos-linux/13113 "2021-11-19T10:43:35Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [November 19, 2021, 10:43am UTC](https://forums.percona.com/t/how-to-install-pmm2-server-through-docker-on-the-custom-data-directory-in-the-centos-linux/13113/1 "2021-11-19T10:43:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [November 19, 2021, 5:49pm UTC](https://forums.percona.com/t/how-to-install-pmm2-server-through-docker-on-the-custom-data-directory-in-the-centos-linux/13113/2 "2021-11-19T17:49:31Z")

</div>

> 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

```

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [November 20, 2021, 4:28am UTC](https://forums.percona.com/t/how-to-install-pmm2-server-through-docker-on-the-custom-data-directory-in-the-centos-linux/13113/3 "2021-11-20T04:28:13Z")

</div>

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 [server102.test.com](http://server102.test.com) 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

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [November 20, 2021, 2:18pm UTC](https://forums.percona.com/t/how-to-install-pmm2-server-through-docker-on-the-custom-data-directory-in-the-centos-linux/13113/4 "2021-11-20T14:18:56Z")

</div>

@Naresh9999  
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

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [November 20, 2021, 4:38pm UTC](https://forums.percona.com/t/how-to-install-pmm2-server-through-docker-on-the-custom-data-directory-in-the-centos-linux/13113/5 "2021-11-20T16:38:46Z")

</div>

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

(OR)

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?

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [November 20, 2021, 7:22pm UTC](https://forums.percona.com/t/how-to-install-pmm2-server-through-docker-on-the-custom-data-directory-in-the-centos-linux/13113/6 "2021-11-20T19:22:04Z")

</div>

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](https://docs.docker.com/config/daemon/#docker-daemon-directory)

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

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [November 21, 2021, 5:52am UTC](https://forums.percona.com/t/how-to-install-pmm2-server-through-docker-on-the-custom-data-directory-in-the-centos-linux/13113/7 "2021-11-21T05:52:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [November 21, 2021, 10:46am UTC](https://forums.percona.com/t/how-to-install-pmm2-server-through-docker-on-the-custom-data-directory-in-the-centos-linux/13113/8 "2021-11-21T10:46:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [November 21, 2021, 7:04pm UTC](https://forums.percona.com/t/how-to-install-pmm2-server-through-docker-on-the-custom-data-directory-in-the-centos-linux/13113/9 "2021-11-21T19:04:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [November 22, 2021, 4:49am UTC](https://forums.percona.com/t/how-to-install-pmm2-server-through-docker-on-the-custom-data-directory-in-the-centos-linux/13113/10 "2021-11-22T04:49:51Z")

</div>

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.
