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?

  • How to store my docker registry in the file system
  • Kubernetes - how to send request to all the minions?
  • Docker - The computer 'WINDOWS10-ON-SE' could not be resolved
  • Using sudo inside non-priviledged docker container not working
  • Docker images with visual(X) support? Or should I use VBox instead in this case?
  • Using mysql image from docker
  • 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

  • Docker Ubuntu with nginx, php-fpm and s3fs but s3fs does not work
  • Eureka can not work with docker? What is different between eureka and consul?
  • How would I pass environment into docker using bash?
  • docker build purely from command line
  • process.env.VARIABLE is undefined in webpack/docker/heroku deployment
  • docker RUN append to /etc/hosts in Dockerfile not working
  • 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.