Newbie question: Odd inaccessible port for rails container

Hey Guys,

I created a docker image with a bare-bones rails app - it just serves up the scaffolding page. I’ve confirmed this with curl.

When I attempt to access the rails (Webbrick) webserver from the host, I consistently get:

$ curl 0.0.0.0:3000
curl: (56) Recv failure: Connection reset by peer

I started up the container with:

$ docker run -u sonnychee -p 3000:3000 -it gc_web:latest

$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a93e70c705d3 gc_web:latest “/bin/bash” 14 minutes ago Up 14 minutes 0.0.0.0:3000->3000/tcp insane_kowalevski

I’ve attempted to start up the webserver in 2 ways and both have yielded the same negative result.

  1. Manually enter the command: rails server in the attached tty
  2. Inserting the “rails server” command in the ~/.bashrc file.

Any suggestions would be very welcome.

Hi,

The problem you are facing is because you are using wrong ip to access the rails server in curl. You should get the containers IP address and do a curl request. You can get the container IP address as shown below.

docker inspect --format '{{ .NetworkSettings.IPAddress }}'  <container ID>

If you are running boot2docker, then you should be using the IP of the boot2docker VM for accessing the service.

Regards

Thanks for the suggestion, rajandas but still no love…

sonnychee@NarBear:~$ docker ps
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS NAMES
c66b66f6e367 gc_web:latest “/bin/bash” 9 seconds
ago Up 9 seconds 0.0.0.0:3000->3000/tcp evil_noyce
sonnychee@NarBear:~$
sonnychee@NarBear:~$
sonnychee@NarBear:~$ docker inspect --format ‘{{ .NetworkSettings.IPAddress
}}’ evil_noyce
172.17.0.1
sonnychee@NarBear:~$ curl http://172.17.0.1:3000
curl: (7) Failed to connect to 172.17.0.1 port 3000: Connection refused

Hi,

Are you using boot2docker? In that case you should use the boot2docker VM IP instead of the container IP

Regards

My host is Ubuntu 14.04.