1

I am creating a Spring Boot monitoring agent that collects docker metrics. The agent can be attached through POM dependency to any client Spring Boot application that runs inside a docker container.

In the agent, I am trying to programatically run docker stats

But, it fails to execute because the docker container doesn't have docker client installed in it.

So how can I run docker commands in docker container? Please note, I can't make changes to the Dockerfile of client.

user2693135
  • 1,206
  • 5
  • 21
  • 44
  • Possible duplicate of [Access Docker socket within container](https://stackoverflow.com/questions/22135897/access-docker-socket-within-container) – David Maze Nov 15 '18 at 00:53
  • Are you trying to run multiple commands inside the docker container? – Keaz Nov 15 '18 at 03:10

1 Answers1

0

You may execute docker commands within the container by defining the docker socket in the container.

run the container and mount the 'docker.sock' in the following manner:

docker run -v /var/run/docker.sock:/var/run/docker.sock ...

so mainly you have to mount docker.sock to order to run docker commands within container.

kj007
  • 6,073
  • 4
  • 29
  • 47