Docker Community Forums

Share and learn in the Docker community.

Not access container for web application


(Tetuya0703) #1

Dear all

I install ubuntu-14.10 to docker 1.2.0, build fa7b24f

I install ubuntu container following command
[command]
docker run -t -i ubuntu /bin/bash

Next a file of included application was prepared in container.
[config.ru]
require 'rubygems’
require ‘bundler’

Bundler.require

require './app’
run App

[Dockerfile]
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get -y install ruby1.9.3
RUN gem install bundler
ADD . /src
RUN cd /src && bundle install
EXPOSE 4567
WORKDIR /src
CMD cd /src && rackup -p4567

[Gemfile]
source 'https://rubygems.org
gem 'sinatra’
gem ‘rack-test’

And container, build, please, an image file was made by following command.
[command]
docker build -t sample-app .

A completed image was carried out by following command.
[command]
docker run -p 4567:4567 -t sample-app
[result]
INFO WEBrick 1.3.1
INFO ruby 1.9.3 (2013-11-22) [x86_64-linux]
INFO WEBrick::HTTPServer#start: pid=8 port=4567

And I accessed container using wget from localhost, but you couldn’t access.
[command]
wget -qO- http://localhost:4567/

Why isn’t it possible to access this?

Please, advice
TETSUYA Saito


(Pregmatch) #2

can you do docker ps -a please?


(Sven Dowideit) #3

is rack defaulting to listening to 127.0.0.1 only? if it is, then that’s the container’s loopback, not your linux box’s loopback - so you need to set it to listening to 0.0.0.0


(Tetuya0703) #4

thanks guys

docker ps -a please
2d68dd943b83 sample-app:latest "/bin/sh -c 'cd /src 28 hours ago Up 28 hours 0.0.0.0:80->80/tcp sharp_feynman
f54f07dc7255 5b1f45074244 "/bin/sh -c 'cd /src 29 hours ago Exited (-1) 28 hours ago sharp_franklin
3f228501effd 345bf3ded526 "/bin/sh -c 'yum -y 29 hours ago Exited (1) 29 hours ago sick_stallman
ee184373c8c8 centos:7 "/bin/sh -c 'apt-get 29 hours ago Exited (127) 29 hours ago focused_engelbart
57be45158c8b sample-app:latest "/bin/sh -c 'cd /src 29 hours ago Exited (-1) 29 hours ago berserk_archimedes
7567735dcb10 httpd:latest "/usr/sbin/httpd -D 29 hours ago Exited (0) 29 hours ago jolly_ardinghelli
95234f52e012 httpd:latest "/usr/sbin/httpd -D 29 hours ago Exited (0) 29 hours ago drunk_ardinghelli
0c9bca720f73 66937f8025ce "/bin/sh -c 'cd /src 47 hours ago Exited (-1) 29 hours ago sad_engelbart
c5dcbac704aa 66937f8025ce "/bin/sh -c 'cd /src 47 hours ago Exited (-1) 47 hours ago prickly_jones
7bc7d6c14f93 db7b5dcc4fca "/bin/sh -c 'cd /src 47 hours ago Exited (1) 47 hours ago distracted_fermi
a5bb6bdfa0dd b1b3ad7dd28a "/bin/sh -c 'cd /src 47 hours ago Exited (1) 47 hours ago happy_bohr
a048f7011a98 4981aa1fe6f6 "/bin/sh -c 'cd /src 47 hours ago Exited (10) 47 hours ago thirsty_kirch
0549e5c88738 f81125d1a032 "/bin/sh -c 'cd /src 47 hours ago Exited (10) 47 hours ago mad_einstein
b1afce4ba8b8 ubuntu:14.04 “/bin/bash” 47 hours ago Exited (0) 47 hours ago nostalgic_pare

is rack defaulting to listening to 127.0.0.1 only? if it is, then that’s the container’s loopback, not your >linux box’s loopback - so you need to set it to listening to 0.0.0.0

I tryed this commans
[command]
wget -qO- http://0.0.0.0:4567/

But, result is same

Plase, advice
regards
TETSUYA Saito


(Sven Dowideit) #5

You can’t talk to the container’s 0.0.0.0, you need the container’s server to listen to 0.0.0.0 - If i’m right, your server is not listening on any ethernet device that you can access from outside the container.


(Tetuya0703) #6

thanks advice
ip address of this container is 172.17.0.28
When ping is performed, this IP address receives a response.
But even if wget -qO- http://172.17.0.28:4567/ is carried out, it’s irresponsive.
Why isn’t it possible to do access of port 4567 of container?

regards
TETSUYA Saito