0

run default image

#  docker run -d --rm -p 8080:80 nginx

Test (linuxmint 20 | Docker version 19.03.12, build 48a66213fe):

~# curl --verbose http://127.0.0.1:8080/todos
*   Trying 127.0.0.1:8080...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /todos HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Empty reply from server
* Connection #0 to host 127.0.0.1 left intact
curl: (52) Empty reply from server

Test (macos 10.15.5 | Docker version 19.03.12, build 48a66213fe):

curl --verbose http://127.0.0.1:8080/todos
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /todos HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Server: nginx/1.19.1
< Date: Sat, 08 Aug 2020 04:20:15 GMT
< Content-Type: text/html
< Content-Length: 153
< Connection: keep-alive
< 
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.19.1</center>
</body>
</html>
* Connection #0 to host 127.0.0.1 left intact
* Closing connection 0

Installed according to the instructions: https://docs.docker.com/engine/install/ubuntu/

Can you please tell me how to fix it?

Kirill Nay
  • 3
  • 1
  • 2

1 Answers1

0

Nginx, by default, hasn't defined the url curl --verbose http://127.0.0.1:8080/todos

Docker proxy is working, since curl --verbose http://127.0.0.1:8080 should work, connecting your host localhost :8080 to nginx :80 inside container.

404 doesn't mean that docker-proxy is not working, but url hasn't been found in your docker configuration. Maybe you have a web code that you didn't add to nginx, or you miss some nginx configuration.

Alejandro Galera
  • 3,445
  • 3
  • 24
  • 42
  • nginx was started by default. (the problem was with linux, not macos) Everything worked when docker was restarted forcibly. The example with macos (and error 404) showed that the image started normally on another system. – Kirill Nay Aug 10 '20 at 11:05
  • Let me insist in my answer. Linux and MacOS what you talk about can have different network interfaces configuration, so, the problem is what I say. Localhost is not the same inside container and in your host unless you run docker with `--net=host` option. – Alejandro Galera Aug 10 '20 at 11:29