Mehdi
Mehdi

Reputation: 2228

Docker stats from java

Please how can I run curl operation for docker-container in Java ? When I run this command on shell

docker stats

I got this result

> CONTAINER           CPU %               MEM USAGE / LIMIT       MEM % 
> NET I/O              BLOCK I/O           PIDS 08b45b1e3f56       
> 0.00%               1.453 MiB / 995.9 MiB   0.15%               1.285 kB / 1.92 kB   0 B / 0 B           2

For this container

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                           NAMES
08b45b1e3f56        nginx               "nginx -g 'daemon off"   14 minutes ago      Up 14 minutes       443/tcp, 0.0.0.0:8000->80/tcp   agitated_boyd

My question is, How can I run this command line (docker stats) from Java program (REST API) and retreive the results?

Upvotes: 0

Views: 929

Answers (1)

Elton Stoneman
Elton Stoneman

Reputation: 19154

The docker CLI just calls into the Docker Remote API.

That's a REST API you can call directly, or use a client wrapper like docker-java.

Upvotes: 2

Related Questions