Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker vs docker-compose nginx: [emerg] host not found in upstream "httpstat.us" in /etc/nginx/nginx.conf:21

I have a very peculiar issue with this set of docker files:

docker run will do what I want whereas docker-compose will not

I'm quite noob'ed with Docker hence this probably rather simple question - and I apologise in advance!

  • but I just cannot pinpoint my err

docker run -p 80:8080 -i -t lakrids_devlakrids 172.17.0.1 - - [01/Feb/2017:23:29:36 +0000] "GET / HTTP/1.1" 200 6979 "-" "curl/7.29.0"

but if I start the same container with docker-compose I get

docker-compose up devlakrids Recreating devlakrids Attaching to devlakrids devlakrids | 2017/02/01 23:28:19 [emerg] 11#11: host not found in upstream "httpstat.us" in /etc/nginx/nginx.conf:21 devlakrids | nginx: [emerg] host not found in upstream "httpstat.us" in /etc/nginx/nginx.conf:21 devlakrids exited with code 1

like image 956
walt_die Avatar asked Dec 06 '25 05:12

walt_die


1 Answers

Two possible culprits:

  • nginx is a funny beast: if the upstream goes down while nginx is already running, then nginx keeps running. However, if upstream is not reachable on nginx start, the latter will fail to start. To solve this you might need to add a startup script to you nginx container testing for upstreams to be up before starting nginx;

  • try to add links explicitly: somehow we had this issue that the nginx docker did not see other machines implicitly defined via compose service names.

Finally, one really forgotten option is: you do not specify anywhere in the files that you show where the httpstat.us service is started within the docker engine, so it is actually surprising that it works for you without compose.

like image 62
Oleg Sklyar Avatar answered Dec 07 '25 20:12

Oleg Sklyar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!