Performing container operations using APIs
In the previous recipe, we launched a container and executed a command inside the container using the /create
, /attach
, and /start
API. In this recipe, we perform a few more operations on the container.
How to do it...
In this recipe, we'll look at a few container operations:
- To list containers, use the following API:

Here are a few examples:
- Here is how to get all the running containers:
$ curl --unix-socket /var/run/docker.sock \ http:/containers/json
- Here is how to get all the running containers, including the stopped ones:
$ curl --unix-socket /var/run/docker.sock \ http:/containers/json?all=1
- To inspect a container, use the following API:

Here is an example of inspecting a container 591ab8ac2650
:
$ curl --unix-socket /var/run/docker.sock \
http:/containers/591ab8ac2650/json
- To get the list of processes running inside a container, use the following API:

Here is an example of listing the process running inside the 591ab8ac2650
container...