Evya2005
Evya2005

Reputation: 438

Docker container running but can't view in browser

I'm new with Docker and i'm trying to run ruby app inside a docker. So i created a ruby app that work and run fine, I also created a image and a docker that when i run and build them it's running just fine. After I running the docker it's shown like it's running without problems, i get an IP from docker inspect and the port shown at docker ps -a as 3000.

when i open the IP:port at the browser I can't see nothing.

here is my docker file:

> FROM ruby:latest 
> 
> # Set the working directory to /app WORKDIR /app
> 
> # Copy the current directory contents into the container at /app ADD . /app
> 
> RUN echo 'debconf debconf/frontend select Noninteractive' |
> debconf-set-selections RUN apt-get update \
>     && DEBIAN_FRONTEND=Noninteractive   apt-get install -y \
>         sqlite3 \
>         thin \
>         nodejs \
>         apt-utils \
>     && bundle install 
> # --no-install-recommends apt-utils sudo
> 
> 
> #RUN sudo -H cp config/initializers/rack_attack.rb config/initializers/rack_attack.rb
> 
> # Install any needed packages specified in requirements.txt
> # RUN pip install -r requirements.txt 
> EXPOSE 3000
> 
> CMD ["bundle",  "exec", "rails", "server"]

Edit:

I tried also with 'Expose 3000' and also run with '-p' flag.
When i run 'docker ps -a' the ports are: '0.0.0.0:32768->3000/tcp'.
For 'docker inspect' i get the IP: '172.17.0.2'

but when i go to 'http://172.17.0.2:3000/' in the browser i see nothing.

NEW EDIT

I discover that the docker is running as tcp6 (IPv6), how can i configure it to be tcp? .

Upvotes: 7

Views: 32628

Answers (2)

Evya2005
Evya2005

Reputation: 438

I found my problem. the solution was to run the docker as production and not as development.

in Dockerfile, instead of:

CMD ["bundle",  "exec", "rails", "server"]

I changed to:

CMD ["bundle",  "exec", "rails", "server", "-e", "production"]

and that solved my problem

Upvotes: 5

humblebee
humblebee

Reputation: 1394

Add this line in your dockerfile:

EXPOSE 3000

Also, if you want this app to be accessible from your host, run with the -p flag.

See "General form" for the run documentation.

Upvotes: 5

Related Questions