0

I have several containers that are running on my Centos7 VM and I would like to retrieve their CPU and Memory usage using the following command:

echo -e "GET /containers/(container_name)/stats HTTP/1.0\r\n" | \
  nc -U /var/run/docker.sock

However, I just receive the following message without any statistics:

HTTP/1.0 200 OK

Server: Docker/1.10.3 (linux)

Date: Sun, 22 Jan 2017 15:53:49 GMT

Content-Type: text/plain; charset=utf-8

The "containers/(container_name)/top" command works fine.

Can you please help me to understand why I don't receive this container's statistics?

mustaccio
  • 18,234
  • 16
  • 48
  • 57
A. Dar
  • 1
  • Are you sure that the `/stats` endpoint is supported in the version of Docker you're running? It looks like you have 1.10.3, which isn't current. – larsks Jan 22 '17 at 21:12
  • You have right, this is the docker version that I use. Is there some way to retrieve the CPU and Memory usage of the containers in this version? Thanks. – A. Dar Jan 23 '17 at 10:21
  • You could simply upgrade the version of docker that you're running. Docker provides packages for centos. – larsks Jan 23 '17 at 12:02

1 Answers1

0

Command to use get the stats of the container:

curl -X GET http://127.0.0.1:6000/containers/<container_id>/stats

The stats will be displayed for every second.

Stats can be fetched only for running containers.

Refer this :

how to configure docker daemon port.

Here_2_learn
  • 5,013
  • 15
  • 50
  • 68