1

Pretty straightforward:

christian@christian:~/development$ docker -v
Docker version 1.6.2, build 7c8fca2

I ran these instructions to start docker.

docker run --detach --name neo4j --publish 7474:7474 \
           --volume $HOME/neo4j/data:/data neo4j

Nothing exciting here; this should all just work. But, http://localhost:7474 doesn't respond. When I jump into the container, it seems to respond just fine (see debug session). What did I miss?

christian@christian:~$ docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                              NAMES
2d9e0d5d2f73        neo4j:latest        "/docker-entrypoint.   15 minutes ago      Up 15 minutes       7473/tcp, 0.0.0.0:7474->7474/tcp   neo4j               
christian@christian:~$ curl http://localhost:7474
^C
christian@christian:~$ time curl http://localhost:7474
^C

real    0m33.353s
user    0m0.008s
sys 0m0.000s
christian@christian:~$ docker exec -it 2d9e0d5d2f7389ed8b7c91d923af4a664471a93f805deb491b20fe14d389a3d2 /bin/bash
root@2d9e0d5d2f73:/var/lib/neo4j# curl http://localhost:7474
{
  "management" : "http://localhost:7474/db/manage/",
  "data" : "http://localhost:7474/db/data/"
}root@2d9e0d5d2f73:/var/lib/neo4j# exit
christian@christian:~$ docker logs 2d9e0d5d2f7389ed8b7c91d923af4a664471a93f805deb491b20fe14d389a3d2 
Starting Neo4j Server console-mode...
/var/lib/neo4j/data/log was missing, recreating...
2016-03-07 17:37:22.878+0000 INFO  No SSL certificate found, generating a self-signed certificate..
2016-03-07 17:37:25.276+0000 INFO  Successfully started database
2016-03-07 17:37:25.302+0000 INFO  Starting HTTP on port 7474 (4 threads available)
2016-03-07 17:37:25.462+0000 INFO  Enabling HTTPS on port 7473
2016-03-07 17:37:25.531+0000 INFO  Mounting static content at /webadmin
2016-03-07 17:37:25.579+0000 INFO  Mounting static content at /browser
2016-03-07 17:37:26.384+0000 INFO  Remote interface ready and available at http://0.0.0.0:7474/
Christian Bongiorno
  • 5,150
  • 3
  • 38
  • 76

3 Answers3

1

I can't reproduce this. Docker 1.8.2. & 1.10.0 is OK with your case:

docker run --detach --name neo4j --publish 7474:7474 neo4j

curl -i 127.0.0.1:7474
HTTP/1.1 200 OK
Date: Tue, 08 Mar 2016 16:45:46 GMT
Content-Type: application/json; charset=UTF-8
Access-Control-Allow-Origin: *
Content-Length: 100
Server: Jetty(9.2.4.v20141103)

{
  "management" : "http://127.0.0.1:7474/db/manage/",
  "data" : "http://127.0.0.1:7474/db/data/"
}

Try upgrade Docker and check netfilter rules for forwarding.

loadaverage
  • 1,028
  • 1
  • 11
  • 16
  • There is no official or even quasi official support on ubuntu 16.04 https://github.com/docker/docker/issues/20192 I will sit on this issue a while longer. I have subscribed to the issue so if they release real support I will know. – Christian Bongiorno Mar 08 '16 at 17:53
  • What netfilter rules should I check? Docker is supposed to manage all that for me. As I already have Java installed this was trivial to run without docker and is proven to be a real PITA with it! – Christian Bongiorno Mar 08 '16 at 17:54
  • GAH! Ok, I don't know why this matters but I have a fix. Will answer my own question. I upvoted you because your answer inspired my change – Christian Bongiorno Mar 08 '16 at 17:56
0

Instead of making the request to localhost you'll want to use the docker-machine VM ip address, which you can determine with this command:

docker-machine inspect default | grep IPAddress

or

curl -i http://$(docker-machine ip default):7474/

The default IP address is 192.168.99.100

William Lyon
  • 8,371
  • 1
  • 17
  • 22
  • I am on linux so docker machine doesn't apply. However, here is the equivalent linux output:christian@christian:~/Downloads/neo4j-community-2.3.2/bin$ docker inspect neo4j | grep IPAddress "IPAddress": "172.17.0.7", christian@christian:~/Downloads/neo4j-community-2.3.2/bin$ time curl 172.17.0.7:7474 ^C real 0m11.309s user 0m0.004s sys 0m0.000s – Christian Bongiorno Mar 07 '16 at 18:21
  • @ChristianBongiorno - Localhost is fine. – Don Branson Mar 07 '16 at 19:48
  • @DonBranson I have substituted: http://localhost http://127.0.0.1 and the IP of the container. It just hangs. – Christian Bongiorno Mar 07 '16 at 21:42
  • Okay. Once it's working, though, localhost should work fine. Since you're specifying the `-p` option, you don't need to use the guest's IP. – Don Branson Mar 07 '16 at 22:01
0

OK, basically I removed the volume mount in the args to docker and it works. Ultimately, I don't want an out-of-container mount anyways. Thank you @LoadAverage for cluing me in. It's still not 'right' but for my purposes I don't care.

christian@christian:~/development$ docker run --detach --name neo4j --publish 7474:7474 neo4j
6c94527816057f8ca1e325c8f9fa7b441b4a5d26682f72d42ad17614d9251170
christian@christian:~/development$ curl http://127.0.0.1:7474
{
  "management" : "http://127.0.0.1:7474/db/manage/",
  "data" : "http://127.0.0.1:7474/db/data/"
}
christian@christian:~/development$ 
Christian Bongiorno
  • 5,150
  • 3
  • 38
  • 76