Docker Community Forums

Share and learn in the Docker community.

Service running on port 4567 only replies within the container


(Martin Stabenfeldt) #1

I get the expected reply when I do curl localhost:4567 within the container, but I only receive an Empty reply from server if I curl from the host machine.

I’m starting the container by running docker-compose up --build .
docker ps returns:
0.0.0.0:4567->4567/tcp

Still, no respons from port 4567. Testing with curl from the host machine.

$ curl 127.0.0.1:4567 # and 0.0.0.0:4567
curl: (52) Empty reply from server

localhost:4567 replies within the containter

$ docker-compose exec web curl localhost:4567
Hello world!%`

What should I do to be able to access the Sinatra app running on port 4567?

Dockerfile

FROM python:3

RUN apt-get update
RUN apt-get install -y ruby rubygems
RUN gem install sinatra

WORKDIR /app
ADD . /app/

EXPOSE 4567
CMD ruby hei.rb -p 4567

hei.rb

require 'sinatra'

get '/' do
  'Hello world!'
end

docker-compose.yml

version: '2'

services:
  web:
    build: .
    ports:
      - "4567:4567"

(Nielsbot) #2

Did you ever find a solution? Having the exact same issue. (macOS)