Docker Rails Server Refusing Connections

I have Rail-Api Server that I setup with my Dockerfile and I’m trying to access it from the host but I a getting Connection refused after starting the rails server and curling the Docker container.



Docker Container : Ports

enter image description here

  • Docker 1.12 Swarm Nodes IP's
  • Launch Docker containers to handle HTTP requests
  • How can I make connection between two services in docker swam?
  • Why is the Node.js AWS-SDK returning the wrong SQS queue URL when creating a local queue
  • Apache and passenger behave differently on Docker mac vs ubuntu
  • Docker web panel with permissions checking
  • iptables -L on ‘docker-machine ssh default’

    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination         
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination         
    DOCKER     all  --  anywhere             anywhere            
    ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
    ACCEPT     all  --  anywhere             anywhere            
    ACCEPT     all  --  anywhere             anywhere            
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination         
    Chain DOCKER (1 references)
    target     prot opt source               destination         
    ACCEPT     tcp  --  anywhere              tcp dpt:5000
    ACCEPT     tcp  --  anywhere              tcp dpt:3000
    ACCEPT     tcp  --  anywhere              tcp dpt:ssh


    FROM centos:6.6
    RUN yum update -y
    RUN yum install git openssl-devel openssh-server sudo openssl readline-devel readline zlib-devel zlib libxml2-devel libxml2 libxslt-devel libxslt nginx tar gcc libaio libaio-devel -y
    RUN rpm -Uvh
    RUN sed -i -e "s/Defaults    requiretty.*/ #Defaults    requiretty/g" /etc/sudoers
    RUN mkdir -p /var/run/sshd
    RUN useradd -m -u 1000 -G wheel deploy && echo '%wheel  ALL=(ALL)  NOPASSWD: ALL' >> /etc/sudoers.d/wheel
    USER deploy
    RUN mkdir ~/dev
    RUN git clone ~/.rbenv/
    RUN git clone ~/.rbenv/plugins/ruby-build
    ENV PATH ~/.rbenv/bin:$PATH
    RUN echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
    RUN source ~/.bash_profile
    ENV CONFIGURE_OPTS --disable-install-doc
    RUN rbenv install 2.2.3
    RUN rbenv global 2.2.3
    RUN bash -l -c 'gem update --system'
    RUN bash -l -c 'gem update'
    RUN bash -l -c 'gem install nokogiri -- --use-system-libraries'
    RUN bash -l -c 'gem install bundler rails-api --no-rdoc --no-ri'
    COPY oracle-instantclient12.1-basic- /tmp/oracle-instantclient12.1-basic-
    COPY oracle-instantclient12.1-devel- /tmp/oracle-instantclient12.1-devel-
    COPY oracle-instantclient12.1-sqlplus- /tmp/oracle-instantclient12.1-sqlplus-
    RUN sudo rpm -Uvh /tmp/oracle-instantclient12.1-basic-
    RUN sudo rpm -Uvh /tmp/oracle-instantclient12.1-devel-
    RUN sudo rpm -Uvh /tmp/oracle-instantclient12.1-sqlplus-
    RUN sudo touch /etc/sysconfig/network
    RUN NLS_LANG=American_America.UTF8
    ENV ORACLE_HOME=/usr/lib/oracle/12.1/client64
    ENV LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
    EXPOSE 22
    EXPOSE 3000
    EXPOSE 5000

  • Commit to jenkins docker image does not save changes
  • volume not getting mounted in nginx container
  • Cannot find module for a node js app running in a docker compose environment
  • which ports should be exposed in a docker container for apache ignite?
  • Port forward for mysql replication (within docker)
  • How to add --restart='always' to container already created
  • One Solution collect form web for “Docker Rails Server Refusing Connections”

    I’m gonna take a wild guess, I think you are using Rails 4.2.x or later (which is the latest as of Today) and its binding to or/and localhost instead of Check this too : What does binding a Rails Server to buy you?

    Try running:

    bundle exec rails server -b0.0.0.0
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.