docker-gen icon indicating copy to clipboard operation
docker-gen copied to clipboard

order of networks in nginx template is random

Open JanMalte opened this issue 3 years ago • 2 comments

I'm not quite sure if this is a docker-gen issue or maybe a nginx-proxy template issue.

I'm using the three container setup for a nginx proxy and noticed multiple nginx restarts due to changed default.conf

Comparing the generated conf files showed me, that the changes are only for the network comment lines.

/nginx-proxy # diff -W 90 -y --suppress-common-lines generated-11.conf generated-12.conf
        # Cannot connect to network 'elm    <
					    >	        # Cannot connect to network 'elmar
        # Cannot connect to network 'git    <
					    >	        # Cannot connect to network 'gitla
        # Cannot connect to network 'hc-    <
					    >	        # Cannot connect to network 'hc-vo
        # Cannot connect to network 'sec    <
					    >	        # Cannot connect to network 'secon
					    >	        # Cannot connect to network 'stats
        # Cannot connect to network 'sta    <
        # Cannot connect to network 'elm    <
					    >	        # Cannot connect to network 'elmar
        # Cannot connect to network 'sec    <
					    >	        # Cannot connect to network 'secon

Related "discussion": https://github.com/nginx-proxy/nginx-proxy/discussions/1981#discussioncomment-2667448

JanMalte avatar May 01 '22 16:05 JanMalte

Fixed in current main branch of nginx-proxy https://github.com/nginx-proxy/nginx-proxy/pull/2183

JanMalte avatar Feb 21 '23 06:02 JanMalte

I'm going to reopen this because I think that a few straightforward tweaks to docker-gen will make life easier for all template authors. Specifically: when order doesn't matter, slices in the template context should be sorted before executing the template. (IIUC, docker-gen currently returns objects in the same order received from Docker, which is apparently not very stable.)

rhansen avatar Feb 21 '23 06:02 rhansen