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.

curl

curl 192.168.99.100:32776

Docker Container : Ports

enter image description here

  • Start container with multiple network interfaces
  • When using Docker Containers, where are shared Python libraries stored?
  • Docker, monitoring container status, alerts
  • Beanstalkd in docker
  • how to build a new docker image and start container
  • docker - Restrictions regarding naming image
  • 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             172.17.0.4           tcp dpt:5000
    ACCEPT     tcp  --  anywhere             172.17.0.4           tcp dpt:3000
    ACCEPT     tcp  --  anywhere             172.17.0.4           tcp dpt:ssh
    

    Dockerfile

    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 https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-12.5.1-1.el6.x86_64.rpm
    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 https://github.com/sstephenson/rbenv.git ~/.rbenv/
    RUN git clone https://github.com/sstephenson/ruby-build.git ~/.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-12.1.0.2.0-1.x86_64.rpm /tmp/oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
    COPY oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm /tmp/oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
    COPY oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm /tmp/oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm
    
    RUN sudo rpm -Uvh /tmp/oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
    RUN sudo rpm -Uvh /tmp/oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
    RUN sudo rpm -Uvh /tmp/oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm
    
    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
    

  • docker run container, how to rerun
  • What is the relation between docker0 and eth0?
  • What is a good style to deploy with docker when docker hub is not available?
  • netcat not returning inside docker
  • docker behind proxy doesn't use system proxy info
  • return from docker-compose up in jenkins
  • 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 127.0.0.1 or/and localhost instead of 0.0.0.0. Check this too : What does binding a Rails Server to 0.0.0.0 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.