0

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"
Matthias
  • 2,622
  • 1
  • 18
  • 29

2 Answers2

1

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.

Adrian Mouat
  • 44,585
  • 16
  • 110
  • 102
  • `EXPOSE` in Dockerfile is just a hint. It changes the behavior of `PublishAllPorts` and `Links` options of [`/containers/create` API endpoint](http://docs.docker.com/reference/api/docker_remote_api_v1.16/#create-a-container), but its lack doesn't prevent from exposing ports using `PortBindings` option. And Fig seems to [just pass](https://github.com/docker/fig/blob/master/compose/service.py#L331) all `ports` from .yml config directly to `/containers/create` endpoint. So I don't see how the lack of `EXPOSE` instruction in Dockerfile can prevent Fig from exposing specified ports. – skozin Feb 09 '15 at 15:53
  • See [examples section of `docker run`](http://docs.docker.com/reference/commandline/cli/#examples_8). Especially this: "`$ sudo docker run -p 127.0.0.1:80:8080 ubuntu bash`: This binds port 8080 of the container to port 80 on 127.0.0.1 of the host machine. `$ sudo docker run --expose 80 ubuntu bash`: This exposes port 80 of the container for use within a link without publishing the port to the host system's interfaces". The `ubuntu` base image obviously doesn't `EXPOSE` port 80. – skozin Feb 09 '15 at 16:01
  • You can test it yourself :) – skozin Feb 09 '15 at 16:02
  • Anyway, the output of `docker port` provided in the question tells that the port actually _gets_ exposed: `9000/tcp -> 127.0.0.1:9000`. – skozin Feb 09 '15 at 16:03
  • So it seems like a problem with the configuration of SonarCube. Unfortunately, I have no experience with this software to suggest what might be wrong. – skozin Feb 09 '15 at 16:06
  • @sam.kozin yeah, you seem to be right. I would argue the EXPOSE documentation is misleading at best. I'll update my answer. – Adrian Mouat Feb 09 '15 at 16:14
  • Yeah, the Docker documentation definitely needs some clarification. Especially everything that is network-related. – skozin Feb 09 '15 at 16:24
  • thanks a lot - the hint that boot2docker had it's own IP address was it. :) – Matthias Feb 11 '15 at 09:05
1

With boot2docker on OSX you need to set up port forwarding. You need to run something like:

VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port9000,tcp,,9000,,9000";

REF: https://github.com/boot2docker/boot2docker/blob/master/doc/WORKAROUNDS.md


Also you need to replace 127.0.0.1 by 0.0.0.0 in your fig.yml file in order to have

- "0.0.0.0:9000:9000"
Céline Aussourd
  • 10,214
  • 4
  • 32
  • 36