-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Host not found in upstream when using bridge network with nginx #12593
Comments
I'm not sure I get it right. Does this error occur in the container ran by compose, or in the second one you run by
The host name is not part of a docker image, this is a runtime information. |
Thank you. Let me elaborate. The typical path would be to set everything up in one single docker compose file. So one might expect something like (abbreviated)
Then in the nginx config, you could access it as above in the nginx.conf My case is different. I have two docker compose setups. One sets up nginx only with certbot and then has that configured nginx listening. Then I have another image made with another docker compose file that I want to reverse proxy into this configured nginx. It seems I need either the IP address of that process or to be able to do the In my setup, I still have the Please let me know if you need additional clarity on my setup. |
To clarify, the error is a runtime error by nginx when it tries to access that route.
But the solution I am using to try and get it to work involves Docker fundamentally. |
My thought is that Docker does something for you automatically when you have the single compose file and that I have to manually recreate that with this setup. |
Compose "just" creates your application container with
|
I just ran docker inspect on my network and some key things are different. I don't have the following fields:
The output does show me IP addresses, Subnet and Gateway. I am pretty sure these are dynamic, though. When I query my app
My understanding is this service name is what goes into the
Since this does not work, there is an extra step it seems. I am trying to figure that out here with this issue. It would work if I had So the open question is still with this particular workflow, what is the best way to get that information to nginx in an automated way for my specific image? Would I query my network and update the nginx.conf dynamically? |
You must inspect the running container. Image doesn't store any of the network settings, those a pure runtime configuration. |
I run the image with the network. I am expecting that all things on the network are aware of that. So is this not the correct behavior:
You do get this behavior with a single compose with everything in it. |
To clarify, this is an example of a working
The line I want to do the same thing with my service called My
As of now, if I try to do the same setup but with a separate image instead of an |
@ndeloof , I think I understand now. Please let me know if this is what you meant. I just ran So I have been expecting that the I ran I had hoped I could spin up the app first, run the |
I believe I need to use the Docker DNS resolver |
That did it. Something like
where |
Description
A
host not found in upstream
error is thrown by nginx when trying to use the name of a service when setting up nginx reverse proxy. The service is built on a different machine than the server and its image is synced. That service has been verified to work as intended on its own on the server machine (before the tls setup). Both the service (web app) and nginx are connected to a named bridge networkmy_bridge_network
. The service is run with the flag to use that network. The nginx instance has this network in its docker-compose service. The expectation is that in the nginx.conf file one can reference the name of the service. But the nginx runtime error demonstrates otherwise.Steps To Reproduce
my_bridge_network
. The image from this is synced to a server.docker run --network my_bridge_network app_image_name
nginx.conf
, I should be able to create a block withlocation / { proxy_pass http://app}
because the image for the app is made from a docker compose service titledapp:
. Docker creates a container calledmy-directory-app
.host not found in upstream "app" in /etc/nginx/conf.d/default.conf:<lineNo>
Compose Version
Docker Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: