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

  • LEMP Kubernetes
  • docker-compose push image to aws ecr
  • using ansible for provisioning docker containers
  • Docker Container Library Duplication
  • restart nginx container when upstream servers is updated
  • Can not pull docker image from private repo when using Minikube
  • 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

  • How to downgrade docker on CoreOS?
  • Determining if a process runs inside lxc/Docker
  • SBT Native Packager Plugin Docker Error
  • Micro-components architecture with python / Django / Drf
  • Should I be using Docker to config a kernel or just the services running on the kernel?
  • The volumes always mount to the /root/ not /crawler/ I specified
  • 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.