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.

2
  • Possible duplicate of Access Docker socket within container Commented Nov 15, 2018 at 0:53
  • Are you trying to run multiple commands inside the docker container? Commented Nov 15, 2018 at 3:10

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.