Docker Community Forums

Share and learn in the Docker community.

Nginx:alpine image is running in docker container and it is using for 8081 port. Why is it showing localhost didn’t send any data error message?


(Poovaraj) #1

nginx:alpine image is running in docker container and it is using for 8081 port. Why is it showing localhost didn’t send any data error message?

image

image

Regards,
Poovaraj


(Metin Y.) #2

you port binding for port 8081 is there.
Are you sure you listen in your nginx.conf also on port 8081?
Instead of responding with yes or no, please paste your nginx.conf!


(Poovaraj) #3

Thanks for your reply !

I have tried to find nginx.conf file in below path but I couldn’t find ngnix folder itself. Can you help me how to find nginx.conf file ?

Path : /etc/nginx/nginx.conf


(Metin Y.) #4

Did you read the image description?


(Poovaraj) #5

yes. I have already read image description. let me check again.


(Ove "Lime" Lindström) #6

All Nginx configuration files are stored under /etc/nginx.

I use this Dockerfile for “static” images such as our proxies:

FROM nginx:latest

ARG working_env

ADD nginx.conf /etc/nginx/nginx.conf
ADD $working_env/conf.d /etc/nginx/conf.d

# Testing all configuration files
RUN nginx -t -c /etc/nginx/nginx.conf

EXPOSE 80 443
CMD ["nginx", "-c", "/etc/nginx/nginx.conf", "-g", "daemon off;"]

And then I use the -p :80 when I start the container.

To do the same with docker-compose I use the something like this:

version: "3.7"

services:
  nginx:
    image: nginx-proxy
    ports:
    - "8081:80"
    volumes:
      - type: bind
        source: ./nginx/nginx.conf
        target: /etc/nginx/nginx.conf
    deploy:
      replicas: 1
      update_config:
        parallelism: 1
        delay: 10s
        max_failure_ratio: 0.1
        order: start-first
      restart_policy:
        condition: on-failure
      placement:
        constraints: [node.role == worker]

This will mount the config from the directory where my docker-compose.yml file is and into the running container. Perfect for testing different configurations.


Docker connection refused between two containers
(Metin Y.) #7

Seems fine to me.

Are you sure that nginx actualy is running and your nginx.conf has correct syntax?
When you do docker service ps {stackname}, you should see the publised (ingress) service port.