Docker Community Forums

Share and learn in the Docker community.

Unable to expose the application

(Negw) #1

Hi, for some reasons I’m unable to expose the application to my network even using -P.

Here is my Dockerfile:

FROM ruby:2.5.1
RUN apt-get update && apt-get install -qq -y build-essential libpq-dev postgresql-client curl apt-utils apt transport-https imagemagick --fix-missing --no-install-recommends
RUN bundle config --global frozen 1
COPY Gemfile Gemfile.lock ./
RUN bundle install
COPY . .
CMD bundle exec foreman start

I start it:

docker container run -P -e RAILS_LOG_TO_STDOUT=1 directory:latest

It starts ok, no errors:

11:21:40 web.1     | Puma starting in single mode...
11:21:40 web.1     | * Version 3.12.0 (ruby 2.5.1-p57), codename: Llamas in Pajamas
11:21:40 web.1     | * Min threads: 5, max threads: 5
11:21:40 web.1     | * Environment: development
11:21:40 web.1     | * Listening on tcp://
11:21:40 web.1     | Use Ctrl-C to stop

If I point my browser to localhost:3000 or it connects to nothing (Unable to connect), pretty sure nothing is answering to that port. If I curl 3000 from inside the container I can see the response I’m expecting.

I’ve tried 3000:3000 as well, same. Interesting fact, if I hist ctrl+c the container doesn’t stop.

Can someone help me? I’m out of guesses


(Rik) #2


The -P flag exposes all exposed ports, but in your Dockerfile you don’t expose any ports.
You can export ports in your Dockerfile with


and use -P

or you can use


to expose port 3000 inside the container to port 3000 on you localhost interface

once this works you can use


to expose the port to the outside