Testing connection to docker daemon

I am writing a script that will boot docker-compose automatically.

However, sometimes, doing eval "$(docker-machine env default)" doesn’t cause the docker daemon to be connected immediatly and when the next line comes (docker-compose up) I get Cannot connect to the Docker daemon. Is the docker daemon running on this host?

  • Follow Symbolic link when creating dockerfile [duplicate]
  • Build docker ubuntu image by Dockerfile
  • Use public container images on IBM Bluemix
  • install Docker CE 17.03 on RHEL7
  • Making multiple Docker Machines accessible across local network. Linux & Mac
  • Do I want a container handling multiple requests?
  • If I use sleep for a few seconds the issue resolves.

    Is there a way to test the connect to daemon via some system tool (checking if a process exists, if a network connect was made, port listened to, etc)? I want to test the docker daemon externally and not use docker cli

  • Prometheus cAdvisor docker monitoring
  • How much memory needed for build docker v1.9.0
  • error installing Tensorflow via docker
  • how to kill lots of docker container processes effectively and faster?
  • When do DockerHub auth tokens expire?
  • Docker: Set container name inside Dockerfile
  • One Solution collect form web for “Testing connection to docker daemon”

    The Docker Remote API has a PING endpoint. You can use the endpoint to check whether you can successfully connect to the Docker daemon. docker-machine env sets the environment variable DOCKER_HOST, so you can use DOCKER_HOST as host to ping. Using nc, you can ping the host as follows:

    $ eval "$(docker-machine env default)"
    $ echo -e "GET /_ping HTTP/1.1\r\n" | nc $DOCKER_HOST
    HTTP/1.1 200 OK
    Server: Docker/1.10.2 (linux)
    Date: Thu, 03 Mar 2016 07:05:58 GMT
    Content-Length: 2
    Content-Type: text/plain; charset=utf-8
    
    OK
    

    You will need to check the return value. If it returns ‘OK’, the connection was successful. A simple check could look as follows (this probably needs more refinement):

    #!/bin/bash
    if [ "$(echo -e "GET /_ping HTTP/1.1\r\n" | nc $DOCKER_HOST | tail -n 1)" == 'OK' ] ; then
      echo "You are connected"
    fi
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.