Skip to content

Conversation

@anlorn
Copy link
Contributor

Hello, I found an issue while setting up nginx-proxy container for my network.

I have the following setup:

  1. network 'A' is a regular network created in docker
  2. network 'B' is an internal network created with --internal parameter

Container with nginx-proxy connected to both A and B networks. At the same time, containers with applications are connected only to 'B' network. When running such a config, I was always getting.

After investigating, I find out that the issue comes from the fact that 'docker inspect' section NetworkSettings.Ports is always empty for internal networks, no matter which port you expose/publish. As the result we always have empty addresses variable when we generate a template. Solution here is to take exposed ports from section Config.ExposedPorts when NetworkSettings.Ports is empty.

How to reproduce:
Create internal network docker network create 'test_network' --internal
Run httpd container connected on this network docker run --network test_network --rm -e VIRTUAL_HOST=test.local -e VIRTUAL_PORT=80 httpd:2.4-alpine
Get latest nginx.tml wget https://raw.githubusercontent.com/nginx-proxy/nginx-proxy/main/nginx.tmpl
Run docker run --network test_network -it --rm -v /run/docker.sock:/tmp/docker.sock -v $(pwd):/app/ jwilder/docker-gen /app/nginx.tmpl
You will see that in the upstream section of the generated config server directive is marked as down.
Repeat all the steps but this time, on step 1, create a network without the --internal parameter.

Docker internak networks have empty map in `NetworkSettings.Ports`. So, docker-gen was returning empty `runtimeContainer.Addresses` for containers on internal networks
@buchdag
Copy link
Member

Superseded by #579

@buchdagbuchdag closed this Dec 19, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@anlorn@buchdag