dockertest: Error when creating docker container: no such host
(Docker version is 1.13.1)
I was using the example MongoDB code to create a mongo container in my test case and encountered this no such host error when connecting:
Post http://unix.sock/containers/create?: dial tcp: lookup unix.sock: no such host
Suspected a OS X platform issue, I also tried to run the test case on Travis CI with the following configuration:
language: go
sudo: required
go:
- 1.7
services:
- docker
but got the same error.
Here is the code that caused the problem, it is essentially same with the example code:
func connectToDockerMongo(t *testing.T) (*dockertest.Pool, *dockertest.Resource) {
pool, err := dockertest.NewPool("")
fatalIfError(t, err)
dockerResource, err := pool.Run("mongo", "3.3", []string{""})
fatalIfError(t, err)
err = pool.Retry(func() error {
var e error
session, e := mgo.Dial(fmt.Sprintf("localhost:%s", dockerResource.GetPort("27017")))
if e != nil {
t.Error(e)
return e
}
return session.Ping()
})
fatalIfError(t, err)
return pool, dockerResource
}
Basically, pool.Run("mongo", "3.3", []string{""}) is failing.
Could someone please help. Thanks!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (10 by maintainers)
Well, you simply need to expose http in the docker general config:
We should probably investigate adding TLS soon here.
must be a windows thing, don’t have that on docker-for-mac yet ¯_(ツ)_/¯