Can't access sinatra service outside of container

Viewed 27

I am getting ERR_EMPTY_RESPONSE in the browser after lunching the Sinatra container in docker. If I connect to the docker container and run curl localhost:4567 it works, but outside of the container - doesn't

web.rb

require 'sinatra'
set :bind, '0.0.0.0'

get '/' do
    'Hello world!'
end

Dockerfile

FROM ruby:3.0.2
EXPOSE 4567
COPY ./web.rb .
RUN gem install sinatra
RUN gem install puma
CMD ["ruby", "web.rb"]
1 Answers

The solution was in binding application to 0.0.0.0 host

require 'sinatra'
set :bind, '0.0.0.0'

get '/' do
    'Hello world!'
end
Related