github.com/hhrutter/nomad@v0.6.0-rc2.0.20170723054333-80c4b03f0705/client/testutil/docker.go (about) 1 package testutil 2 3 import ( 4 "testing" 5 6 docker "github.com/fsouza/go-dockerclient" 7 "github.com/hashicorp/nomad/testutil" 8 ) 9 10 // DockerIsConnected checks to see if a docker daemon is available (local or remote) 11 func DockerIsConnected(t *testing.T) bool { 12 // We have docker on travis so we should try to test 13 if testutil.IsTravis() { 14 return true 15 } 16 17 client, err := docker.NewClientFromEnv() 18 if err != nil { 19 return false 20 } 21 22 // Creating a client doesn't actually connect, so make sure we do something 23 // like call Version() on it. 24 env, err := client.Version() 25 if err != nil { 26 t.Logf("Failed to connect to docker daemon: %s", err) 27 return false 28 } 29 30 t.Logf("Successfully connected to docker daemon running version %s", env.Get("Version")) 31 return true 32 }