Search code examples
dockergetrequestget-request

Write GET request for docker


Dockerd daemon gives me such output:

ERRO[2857] Handler for GET /v1.26/containers/jupyter-user/json returned error: No such container: jupyter-user 

How can I write GET-request in terminal to docker daemon to see such output?


Solution

  • Docker exposes restful API on its daemon, you can use any CLI HTTP client tool to get such information. Docker daemon option -H is where it listens incoming requests. Take cURL as example:

    • If your docker daemon only binds to unix domain socket like -H unix:///var/run/docker.sock, then you need the latest cURL which supports --unix-socket option, I'm using curl 7.52.1 to run the following command on docker host:

      $> curl --unix-socket /var/run/docker.sock http:/v1.23/containers/unexisted_container/json
      No such container: unexisted_container
      
    • If your docker daemon binds to TCP port like -H tcp://0.0.0.0:4322, the above command would be:

      $> curl http://<host_ip>:4322/v1.23/containers/unexisted_container/json
      

    You can refer to docs of docker engine API for more details.