Search code examples
dockerfig

docker/fig: port forwarding to guest machine does not work on MacOS


I am trying to get this fig image here up and running: https://registry.hub.docker.com/u/harbur/sonarqube/

docker and fig installed fine and also the two images boot normally (including the applications - checked from the logs). however, there should be a port forwarding setup so that I can connect from my host machine to the sonarqube instance. however, I can't connect to the machines as no port is open on the host OS.

Is there anybody who can give me a hint on what I'm doing wrong?

Cheers, Matthias

$ docker port dockersonarqube_sonarqube_1
443/tcp -> 0.0.0.0:49154
9000/tcp -> 127.0.0.1:9000
$ curl 127.0.0.1:9000
curl: (7) Failed connect to 127.0.0.1:9000; Connection refused

this is the fig config file:

postgresql:
  image: orchardup/postgresql:latest
  environment:
    - POSTGRESQL_USER=sonar
    - POSTGRESQL_PASS=xaexohquaetiesoo
    - POSTGRESQL_DB=sonar
  volumes:
    - /opt/db/sonarqube/:/var/lib/postgresql
sonarqube:
  image: harbur/sonarqube:latest
  links:
    - postgresql:db
  environment:
    - DB_USER=sonar
    - DB_PASS=xaexohquaetiesoo
    - DB_NAME=sonar
  ports:
    - "127.0.0.1:9000:9000"
    - "443"

Solution

  • If you're using boot2docker on a Mac, you need to access the website via the VM. You'll need to do two things:

    • Expose the VM port on all interfaces by changing "127.0.0.1:9000:9000" to "0.0.0.0:9000:9000".
    • Use the IP of the VM to connect to the server e.g. curl $(boot2docker ip 2> /dev/null):9000

    You shouldn't need to muck with port forwarding inside the VM unless you really don't like using the boot2docker IP rather than 0.0.0.0.