# How to create pmm-client in docker container to monitor MySQL database (in seperate a container)

**URL:** <https://forums.percona.com/t/how-to-create-pmm-client-in-docker-container-to-monitor-mysql-database-in-seperate-a-container/37802>\
**Category:** Uncategorized\
**Created:** [May 2, 2025, 11:27am UTC](https://forums.percona.com/t/how-to-create-pmm-client-in-docker-container-to-monitor-mysql-database-in-seperate-a-container/37802 "2025-05-02T11:27:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sh123](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@sh123](https://forums.percona.com/u/sh123)\
**Post date:** [May 2, 2025, 11:27am UTC](https://forums.percona.com/t/how-to-create-pmm-client-in-docker-container-to-monitor-mysql-database-in-seperate-a-container/37802/1 "2025-05-02T11:27:58Z")

</div>

I was following these instructions here to setup pmm-client in a container: [Set up PMM Client - Percona Monitoring and Management](https://docs.percona.com/percona-monitoring-and-management/2/setting-up/client/index.html#docker)

I’m running version 2.3.5, but I’m then struggling to get the pmm-agent to add MySQL monitoring service for a MySQL database that’s hosted in the same server but on another container.

The documentation here seems to only explain if it’s hosted in the same instance: [MySQL - Percona Monitoring and Management](https://docs.percona.com/percona-monitoring-and-management/2/setting-up/client/mysql.html#add-service)

---

<div class="post-metadata">

**Author:** ![Ivan\_Groenewold](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ivan_groenewold/32/6299_2.png) [@Ivan\_Groenewold](https://forums.percona.com/u/Ivan_Groenewold)\
**Post date:** [May 2, 2025, 12:59pm UTC](https://forums.percona.com/t/how-to-create-pmm-client-in-docker-container-to-monitor-mysql-database-in-seperate-a-container/37802/2 "2025-05-02T12:59:13Z")

</div>

Hi, first start pmm-client container as per the doc page:

```auto
PMM_SERVER=X.X.X.X:443
docker run \
--rm \
--name pmm-client \
-e PMM_AGENT_SERVER_ADDRESS=${PMM_SERVER} \
-e PMM_AGENT_SERVER_USERNAME=admin \
-e PMM_AGENT_SERVER_PASSWORD=admin \
-e PMM_AGENT_SERVER_INSECURE_TLS=1 \
-e PMM_AGENT_SETUP=1 \
-e PMM_AGENT_CONFIG_FILE=config/pmm-agent.yaml \
--volumes-from pmm-client-data \
percona/pmm-client:2

```

then after starting the PMM Client container, add the mysql service as follows:

```auto
docker exec -it <name_of_pmm_client_container> /bin/bash
pmm-admin add mysql --username=<pmm_user> --password=<pmm_pass> --host=<name_of_mysqld_container> --port=<port_of_mysqld_container>

```

---

<div class="post-metadata">

**Author:** ![sh123](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@sh123](https://forums.percona.com/u/sh123)\
**Post date:** [May 8, 2025, 11:04pm UTC](https://forums.percona.com/t/how-to-create-pmm-client-in-docker-container-to-monitor-mysql-database-in-seperate-a-container/37802/3 "2025-05-08T23:04:59Z")

</div>

Thanks when I run that command to create the docker container, I know the --rm flag is supposed to indicate short-lived container. When I execute that command to create the container, it’s only running while I have my terminal open, as soon as I exit the terminal. The container is stopped, how do i get it to continiously run? As I plan to have it keep running so I can monitor the MySQL database that’s hosted on another container?

---

<div class="post-metadata">

**Author:** ![Agustin\_G](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/agustin_g/32/14111_2.png) [@Agustin\_G](https://forums.percona.com/u/Agustin_G)\
**Post date:** [May 9, 2025, 12:05am UTC](https://forums.percona.com/t/how-to-create-pmm-client-in-docker-container-to-monitor-mysql-database-in-seperate-a-container/37802/4 "2025-05-09T00:05:09Z")

</div>

Hi,

Instead of --rm use -d (detached):

> **[docker container run](https://docs.docker.com/reference/cli/docker/container/run/#detach)**

---

<div class="post-metadata">

**Author:** ![sh123](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@sh123](https://forums.percona.com/u/sh123)\
**Post date:** [May 13, 2025, 3:39pm UTC](https://forums.percona.com/t/how-to-create-pmm-client-in-docker-container-to-monitor-mysql-database-in-seperate-a-container/37802/5 "2025-05-13T15:39:20Z")

</div>

I’m having issues adding mysql monitoring to the pmm-agent.

So if I run

```auto
docker ps -a

```

These are the details returned (where MySQL is installed in the container named mysql3) running in port 3308:

```auto
f681XXXXXX percona/pmm-client:2.35.0 "/usr/local/percona/…" 41 minutes ago Up 41 minutes pmm-client
d135XXXXXX mysql/mysql-server:8.0.35 "/entrypoint.sh mysq…" 5 weeks ago Up 5 weeks (healthy) 33061/tcp, 0.0.0.0:3308->3306/tcp, 0.0.0.0:33080->33060/tcp mysql3

```

So I try to run this command to get pmm-client monitoring the MySQL database that’s hosted in container name “mysql3”:

```auto
docker exec -it pmm-client /bin/bash
pmm-admin add mysql --username=test --password=test123 --host=mysql3 --port=3308

```

But get this error:

> Connection check failed: dial tcp: lookup mysql3 on 13.XX.XXX.XXX: no such host.

So I then tried to supply the ip-address of the server (host) that has the pmm-client and mysql databases hosted in docker containers:

```auto
 pmm-admin add mysql --username=test --password=test123 --host=13.XX.XXX.XXX --port=3308

```

But get the following error:

> Connection check failed: dial tcp 13.XX.XXX.XXX:3308: i/o timeout.

Any idea what I’m doing wrong? My server is hosted in AWS, I tried using the ipv4 ip-address and the private one but neither works and give timeout error. I recalled your old percona monitoring software had an option to bind-address, which I don’t see as an option.

---

<div class="post-metadata">

**Author:** ![Ivan\_Groenewold](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ivan_groenewold/32/6299_2.png) [@Ivan\_Groenewold](https://forums.percona.com/u/Ivan_Groenewold)\
**Post date:** [May 13, 2025, 4:09pm UTC](https://forums.percona.com/t/how-to-create-pmm-client-in-docker-container-to-monitor-mysql-database-in-seperate-a-container/37802/6 "2025-05-13T16:09:42Z")

</div>

it seems your pmm-client container cannot reach your mysql server host/port. Are you sure everything is in the same docker network? do you have anything controlling access to your mysql host and port 3308?

---

<div class="post-metadata">

**Author:** ![sh123](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@sh123](https://forums.percona.com/u/sh123)\
**Post date:** [May 13, 2025, 4:20pm UTC](https://forums.percona.com/t/how-to-create-pmm-client-in-docker-container-to-monitor-mysql-database-in-seperate-a-container/37802/7 "2025-05-13T16:20:29Z")

</div>

Yesn when I run docker network inspect the network id from the container mysql database is running on and the container pmm-client is runing on both return the same network id. I don’t have anything else controlling access to mysql host and port 3308.

---

<div class="post-metadata">

**Author:** ![Agustin\_G](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/agustin_g/32/14111_2.png) [@Agustin\_G](https://forums.percona.com/u/Agustin_G)\
**Post date:** [May 13, 2025, 7:04pm UTC](https://forums.percona.com/t/how-to-create-pmm-client-in-docker-container-to-monitor-mysql-database-in-seperate-a-container/37802/8 "2025-05-13T19:04:09Z")

</div>

Hi,

Docker ps outputs show the following for the MySQL container:

```auto
0.0.0.0:3308->3306/tcp

```

This means that port 3306 from the container is mapped to 3308 on the host.

You are logging in to the PMM client container, and trying to use port 3308 (the one exposed on the host) with the MySQL container (host = mysql3).

Try using port 3306:

```auto
docker exec -it pmm-client /bin/bash
pmm-admin add mysql --username=test --password=test123 --host=mysql3 --port=3306

```

If they are indeed in the same docker network, this will work.

---

<div class="post-metadata">

**Author:** ![sh123](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@sh123](https://forums.percona.com/u/sh123)\
**Post date:** [May 13, 2025, 8:42pm UTC](https://forums.percona.com/t/how-to-create-pmm-client-in-docker-container-to-monitor-mysql-database-in-seperate-a-container/37802/9 "2025-05-13T20:42:01Z")

</div>

That didn’t work, I get the same error:

> Connection check failed: dial tcp: lookup mysql3 on 172.XX.X.X:53: no such host.

If i run

```auto
docker inspect mysql3

```

I get:

> “NetworkSettings”: {  
> “Bridge”: “”,  
> “SandboxID”:  
> “Ports”: {  
> “3306/tcp”: [  
> {  
> “HostIp”: “0.0.0.0”,  
> “HostPort”: “3308”  
> }  
> ],  
> “33060/tcp”: [  
> {  
> “HostIp”: “0.0.0.0”,  
> “HostPort”: “33080”  
> }  
> ],  
> “33061/tcp”: null  
> },

> “Networks”: {  
> “bridge”: {  
> “NetworkID”: “4abXXXb8”,  
> }  
> }

Which matches the network id when I run the same thing for pmm-client container:

```auto
docker inspect pmm-client

```

> “Networks”: {  
> “bridge”: {  
> “NetworkID”: “4abXXXb8”,  
> }  
> }

---

<div class="post-metadata">

**Author:** ![Agustin\_G](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/agustin_g/32/14111_2.png) [@Agustin\_G](https://forums.percona.com/u/Agustin_G)\
**Post date:** [May 13, 2025, 10:51pm UTC](https://forums.percona.com/t/how-to-create-pmm-client-in-docker-container-to-monitor-mysql-database-in-seperate-a-container/37802/10 "2025-05-13T22:51:49Z")

</div>

Hi,

```auto
Connection check failed: dial tcp: lookup mysql3 on 172.XX.X.X:53: no such host.

```

“No such host” means that the docker dns is not being able to resolve “mysql3” as hostname, so there’s something wrong with it.  
Can you share the exact commands you used to deploy these two containers? Have you also tried connecting from the pmm-client to the (docker) host and port 3308?

---

<div class="post-metadata">

**Author:** ![sh123](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@sh123](https://forums.percona.com/u/sh123)\
**Post date:** [May 13, 2025, 11:03pm UTC](https://forums.percona.com/t/how-to-create-pmm-client-in-docker-container-to-monitor-mysql-database-in-seperate-a-container/37802/11 "2025-05-13T23:03:17Z")

</div>

Ok my bad it didn’t look like they were in the same network. Ran these command to fix this issue:

```auto
docker network create percona-con
docker network connect percona-con mysql3
docker network connect percona-con pmm-client

```

Then

```auto
docker exec -it pmm-client /bin/bash
pmm-admin add mysql --username=test --password=test123 --host=mysql3 --port=3306

```

and that worked!
