I am running a rails app inside of a docker container but trying to reach it from a browser the browser shows ERR_CONNECTION_REFUSED . when running docker ps I get
a086ed5a6c4a        rails                       "bash"                   3 days ago          Up About an hour    0.0.0.0:3000->3000/tcp                                                            rails
then when running docker inspect rails I see the gateway is "Gateway": "172.17.0.1"
when I try and ping 172.17.0.1 it works but if I ping 172.17.0.1:3000 it doesn't work.
when I try nmap -p 3000 172.17.0.1 I get 
Starting Nmap 6.40 ( http://nmap.org ) at 2015-12-12 15:27 PST
Nmap scan report for 172.17.0.1
Host is up (0.000047s latency).
PORT     STATE  SERVICE
3000/tcp closed ppp
running sudo netstat -tulpn I get the following.
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:5940          0.0.0.0:*               LISTEN      1900/teamviewerd
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN      5965/dnsmasq    
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      1195/dnsmasq    
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      2910/cupsd      
tcp6       0      0 :::5858                 :::*                    LISTEN      4693/docker-proxy
tcp6       0      0 :::4200                 :::*                    LISTEN      4629/docker-proxy
tcp6       0      0 :::6379                 :::*                    LISTEN      4423/docker-proxy
tcp6       0      0 :::8080                 :::*                    LISTEN      4665/docker-proxy
tcp6       0      0 ::1:53                  :::*                    LISTEN      1195/dnsmasq    
tcp6       0      0 ::1:631                 :::*                    LISTEN      2910/cupsd      
tcp6       0      0 :::5432                 :::*                    LISTEN      4540/docker-proxy
tcp6       0      0 :::3000                 :::*                    LISTEN      3099/docker-proxy
tcp6       0      0 :::3001                 :::*                    LISTEN      4700/docker-proxy
tcp6       0      0 :::3002                 :::*                    LISTEN      6521/docker-proxy
tcp6       0      0 :::7357                 :::*                    LISTEN      4610/docker-proxy
udp        0      0 0.0.0.0:27824           0.0.0.0:*                           6091/dhclient   
udp        0      0 0.0.0.0:53717           0.0.0.0:*                           569/avahi-daemon: r
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           3206/chrome     
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           569/avahi-daemon: r
udp        0      0 0.0.0.0:5699            0.0.0.0:*                           5961/dhclient   
udp        0      0 127.0.1.1:53            0.0.0.0:*                           5965/dnsmasq    
udp        0      0 127.0.0.1:53            0.0.0.0:*                           1195/dnsmasq    
udp        0      0 0.0.0.0:68              0.0.0.0:*                           6091/dhclient   
udp        0      0 0.0.0.0:68              0.0.0.0:*                           5961/dhclient   
udp        0      0 0.0.0.0:631             0.0.0.0:*                           1336/cups-browsed
udp6       0      0 :::53862                :::*                                5961/dhclient   
udp6       0      0 :::5353                 :::*                                569/avahi-daemon: r
udp6       0      0 ::1:53                  :::*                                1195/dnsmasq    
udp6       0      0 :::59093                :::*                                569/avahi-daemon: r
udp6       0      0 :::26992                :::*                                6091/dhclient   
Go to performance and then CPU to verify whether Virtualization is enabled or not. If virtualization is disabled Docker Desktop cannot start. If the virtualization is disabled in your machine then you need to enable it from BIOS Settings.
Listen to Connections in the Docker Network The bridge connection docker0 – with IP address 172.17. 0.1 – is created by Docker at installation time. Because the host and all containers are connected to that network, our application only needs to listen to it.
Try binding the Rails server to 0.0.0.0, which tells it to bind to all the IP addresses on the Docker host. It's only bound to localhost by default, which was changed recently, as explained in this answer. This is done with the -b argument to rails server:
docker run -p 3000:3000 -d rails server -p 3000 -b 0.0.0.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With