[SOLVED] Build error: Server not connecting to dockerhost

I’ve followed the instructions to set up a dev machine as laid out in the docs. (Mac OS)

I have Docker Tools for Mac installed.

When I run make run-server I get the following error:

mattermost-server$ make run-server
Starting docker containers
restarting mattermost-mysql
restarting mattermost-postgres
restarting mattermost-inbucket
restarting mattermost-minio
Running mattermost for development
mkdir -p ../mattermost-webapp/dist/files
go run  -ldflags "-X github.com/mattermost/mattermost-server/model.BuildNumber=dev -X 'github.com/mattermost/mattermost-server/model.BuildDate=Mon  9 Jul 2018 04:20:53 UTC' -X github.com/mattermost/mattermost-server/model.BuildHash=516a097e1ad588d860b374ef1d0eff202adb286b -X github.com/mattermost/mattermost-server/model.BuildHashEnterprise=none -X github.com/mattermost/mattermost-server/model.BuildEnterpriseReady=false" "./cmd/mattermost/main.go" --disableconfigwatch &
mattermost-server$ {"level":"info","ts":1531110057.431201,"caller":"utils/i18n.go:83","msg":"Loaded system translations for 'en' from '/Users/farah/go/src/github.com/mattermost/mattermost-server/i18n/en.json'"}
{"level":"info","ts":1531110057.431747,"caller":"app/app.go:186","msg":"Server is initializing..."}
{"level":"debug","ts":1531110057.4317942,"caller":"utils/html.go:29","msg":"Parsing server templates at /Users/farah/go/src/github.com/mattermost/mattermost-server/templates"}
{"level":"info","ts":1531110057.4401772,"caller":"sqlstore/supplier.go:200","msg":"Pinging SQL master database"}
{"level":"error","ts":1531110057.5350754,"caller":"sqlstore/supplier.go:212","msg":"Failed to ping DB retrying in 10 seconds err=dial tcp: lookup dockerhost: no such host"}

Running docker ps

CONTAINER ID        IMAGE                              COMMAND                  CREATED             STATUS                             PORTS                                                         NAMES
349e74d6251a        minio/minio:latest                 "/usr/bin/docker-ent…"   14 hours ago        Up 22 seconds (health: starting)   0.0.0.0:9001->9000/tcp                                        mattermost-minio
8f9951e9cdb1        jhillyerd/inbucket:release-1.2.0   "/con/context/start-…"   14 hours ago        Up 23 seconds                      10110/tcp, 0.0.0.0:2500->10025/tcp, 0.0.0.0:9000->10080/tcp   mattermost-inbucket
e9151f814182        postgres:9.4                       "docker-entrypoint.s…"   14 hours ago        Up 23 seconds                      0.0.0.0:5432->5432/tcp                                        mattermost-postgres
9f5346f0be23        mysql:5.7                          "docker-entrypoint.s…"   14 hours ago        Up 24 seconds                      0.0.0.0:3306->3306/tcp                                        mattermost-mysql

Screenshot of Kitamatic:

I’m a bit curious about the localhost:3306 under hostsname/ports, is it correct? In the mattermost config json I’m pretty sure it was dockerhost:3306 which it’s complaining it can’t connect to.

What’s really strange is that I can curl localhost:.3306 and connect to the database if I replace dockerhost with localhost in the database url.

The problem seems to be that dockerhost simply cannot be resolved. Any one got any reasons why?

I have replaced every mention of dockerhost to localhost in the sourcecode yet I still see

[2018/07/09 16:07:46 AEST] [EROR] Failed to ping DB retrying in 10 seconds err=dial tcp: lookup dockerhost: no such host

This is crazy

Hi @mike! Thank you for reporting this.

@jesse I’ll need dev help here to look at this - feel free to ping other devs too.

1 Like

Thanks for the question, @mike!

We recently reworked our developer documentation, and it looks like the OSX setup instructions omitted a step (which is present for other targets), namely that we currently require editing your host files and defining an alias on localhost:

127.0.0.1     dockerhost 

This isn’t strictly necessary, of course, but it makes things a bit more flexible if you ever host your Docker development environment somewhere other than localhost.

Hope that helps! We’ll patch up our documentation :slight_smile:

2 Likes

This has solved my issue, thanks!