Vikas Banage
Vikas Banage

Reputation: 514

0.0.0.0 refused to connect

I want to deploy simple static website as Non-Root user with Docker. I have created Docker file with below content:

FROM nginx:stable

COPY ./nginx.conf /etc/nginx/nginx.conf
COPY ./site.conf /etc/nginx/conf.d/default.conf
COPY . /usr/share/nginx/html


RUN touch /var/run/nginx.pid && \
  chown -R 1000:1000 /var/run/nginx.pid && \
  chown -R 1000:1000 /var/cache/nginx

USER 1000

VOLUME /var/www

EXPOSE 8086

File Structure

I build Docker with below command:

docker build -t ubdashboard:v4

Running with below command

docker run -d -p 8086:80 ubdashboard:v4

I can see below container is running:

edureka@edureka:~/dashboard$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                            NAMES
a74332a5f568        ubdashboard:v4      "nginx -g 'daemon ..."   7 seconds ago       Up 6 seconds        8086/tcp, 0.0.0.0:8086->80/tcp   flamboyant_jang

But when I try to access 0.0.0.0:8086 or 0.0.0.0:80 , below message in Google chrome: This site can’t be reached

The web page at http://0.0.0.0:8086/ might be temporarily down or it may have moved permanently to a new web address.

Please guide here.

Upvotes: 1

Views: 7739

Answers (1)

Simonluca Landi
Simonluca Landi

Reputation: 921

Exploding the commment from Gerben Jongerius:

8086/tcp, 0.0.0.0:8086->80/tcp 

means that the port 80/tcp on the container is mapped to the port 8086 on ALL the ips of your host (the machine where docekr is running).

To access the nginx server you can open http://127.0.0.1:8086 on your host.

Upvotes: 2

Related Questions