Fedor Kovalev
Fedor Kovalev

Reputation: 23

Docker nginx container: http code 400

I’m a new in docker and I’m trying to run nginx from https://hub.docker.com/_/nginx/

  1. I pulled the image

docker pull nginx

  1. I’m running container

docker run --rm --name=some-nginx -p 8080:80 nginx

but getting http 400 all time when I open localhost:8080 in browser in local machine. Log from docker output:

172.17.0.1 - - [14/Dec/2017:23:07:11 +0000] "\x16\x03\x01\x00\xB5\x01\x00\x00\xB1\x03\x03\x81e|u\x93\xFC`Qo\xC8\xE6y\x18{%\x83\x8C\xC2a\xC93V\xB5;\xC0V\xDC\x10{\xC9)X\x00\x00\x1E\xC0+\xC0/\xCC\xA9\xCC\xA8\xC0,\xC00\xC0" 400 173 "-" "-" "-"

What’s wrong? I checked nginx inside the containter (curl localhost) and it works.

Thank you.

Upvotes: 2

Views: 2081

Answers (1)

Fabiano
Fabiano

Reputation: 1413

I got it now. It's a bit complicated, but I will try to simplify:

You are binding the 8080 host port to 80 container port. So, if you do a curl localhost at the host, it means you are not calling Nginx service inside the container, but the port 80 process in your *nix system. Likewise, if you send the same command inside the container, it will work, because it has exposed the default http port (80) inside the container, but not outside. You may confirm this assumption by calling curl localhost:8080. If this return as the container command, it is right.

Is it possible to understand?

Upvotes: 2

Related Questions