2

I need to get all the stopped containers list via an API. but I got only commands to get the list.

If APIs are not available, suggest how we can create an API with docker commands. so whenever I hit the API, I can get the list of stopped containers.

Vasanthi
  • 37
  • 6

1 Answers1

1

First, if you need other pc to visit docker daemon you need to enable it in /lib/systemd/system/docker.service, like next:

ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375

Second, you could use next url to paste to browser to get all containers like exit:

http://10.192.244.188:2375/containers/json?filters={"status":["exited"]}

If use curl, then you may need to url encode some special html entity like next:

curl http://10.192.244.188:2375/containers/json?filters=%7B%22status%22%3A%5B%22exited%22%5D%7D

You could also use next to make it easy to read:

curl http://10.192.244.188:2375/containers/json?filters=%7B%22status%22%3A%5B%22exited%22%5D%7D | python -m json.tool
atline
  • 28,355
  • 16
  • 77
  • 113