question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

no servers inside upstream in /etc/nginx/conf.d/default.conf

See original GitHub issue

Description

On my x86 fedora 33 server environment I face the following issue with latest nginx-proxy image. The automatic default.conf generation seems to fail and results in an empty upstream configuration.

Steps to Reproduce

I use this minimal example:

version: '2'

services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro

  whoami:
    image: jwilder/whoami
    environment:
      - VIRTUAL_HOST=whoami.local

Startup log:

 admin@tpdachsserver:~/repos/reverse-proxy-test    ▶  docker-compose up              
Creating network "reverse-proxy-test_default" with the default driver
Creating reverse-proxy-test_nginx-proxy_1 ... done
Creating reverse-proxy-test_whoami_1      ... done
Attaching to reverse-proxy-test_whoami_1, reverse-proxy-test_nginx-proxy_1
whoami_1       | Listening on :8000
nginx-proxy_1  | WARNING: /etc/nginx/dhparam/dhparam.pem was not found. A pre-generated dhparam.pem will be used for now while a new one
nginx-proxy_1  | is being generated in the background.  Once the new dhparam.pem is in place, nginx will be reloaded.
nginx-proxy_1  | forego     | starting dockergen.1 on port 5000
nginx-proxy_1  | forego     | starting nginx.1 on port 5100
nginx-proxy_1  | dockergen.1 | 2021/01/02 03:07:54 Generated '/etc/nginx/conf.d/default.conf' from 2 containers
nginx-proxy_1  | dockergen.1 | 2021/01/02 03:07:54 Running 'nginx -s reload'
nginx-proxy_1  | dockergen.1 | 2021/01/02 03:07:54 Error running notify command: nginx -s reload, exit status 1
nginx-proxy_1  | dockergen.1 | 2021/01/02 03:07:54 Watching docker events
nginx-proxy_1  | dockergen.1 | 2021/01/02 03:07:54 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
nginx-proxy_1  | 2021/01/02 03:07:55 [emerg] 47#47: no servers are inside upstream in /etc/nginx/conf.d/default.conf:58
nginx-proxy_1  | nginx: [emerg] no servers are inside upstream in /etc/nginx/conf.d/default.conf:58
nginx-proxy_1  | Generating DSA parameters, 4096 bit long prime
nginx-proxy_1  | dhparam generation complete, reloading nginx
nginx-proxy_1  | nginx.1    | 172.28.0.1 - - [02/Jan/2021:03:11:18 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.71.1" "-"

As a consequence curl request returns the following:

Curl request

admin@tpdachsserver:~    ▶  curl -H "Host: whoami.local" localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

Please expand to see the resulting configuration:

default.conf

 admin@tpdachsserver:~/repos/reverse-proxy-test $  docker exec -it reverse-proxy-test_nginx-proxy_1 cat /etc/nginx/conf.d/default.conf 
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
  default $http_x_forwarded_proto;
  ''      $scheme;
}
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
# server port the client connected to
map $http_x_forwarded_port $proxy_x_forwarded_port {
  default $http_x_forwarded_port;
  ''      $server_port;
}
# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection {
  default upgrade;
  '' close;
}

# Apply fix for very long server names
server_names_hash_bucket_size 128;
# Default dhparam
ssl_dhparam /etc/nginx/dhparam/dhparam.pem;
# Set appropriate X-Forwarded-Ssl header
map $scheme $proxy_x_forwarded_ssl {
  default off;
  https on;
}
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
log_format vhost '$host $remote_addr - $remote_user [$time_local] '
                 '"$request" $status $body_bytes_sent '
                 '"$http_referer" "$http_user_agent"';
access_log off;
		ssl_protocols TLSv1.2 TLSv1.3;
		ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
		ssl_prefer_server_ciphers off;
resolver 127.0.0.11;
# HTTP 1.1 support
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
# Mitigate httpoxy attack (see README for details)
proxy_set_header Proxy "";
server {
	server_name _; # This is just an invalid value which will never trigger on a real hostname.
	listen 80;
	access_log /var/log/nginx/access.log vhost;
	return 503;
}
# whoami.local
upstream whoami.local {
}
server {
	server_name whoami.local;
	listen 80 ;
	access_log /var/log/nginx/access.log vhost;
	location / {
		proxy_pass http://whoami.local;
	}
}

Pre-Analysis

I found one common issue which often results in this behaviour. It needs to be ensured the started containers are really in the same network and can reach each other. I tried many variants with external network and manually adding the containers to that network etc. All without success.

The second hint I found is that in some cases cgroup might be a reason .Docker.CurrentContainerID, used in nginx.tmpl, can’t be resolved. Since Fedora33 uses cgroup2 there might be a link. However, I lack the debug knowledge on how to check whether .Docker.CurrentContainerID is empty or not. I tried this very same example on an Debian Stretch server with 4.9 Kernel. Here the default.conf gets configured correctly. Thus, I assume some relation to the host environment.

Please let me know the supported Information is not sufficient. I’m grateful for any kind of support. TIA

Thanks, Steffen

Update #1

After some investigation I found that CurrentContainerID is empty and docker-gen can not get the information to fill the template. I prepared a RFC PR and a preliminary fix here: https://github.com/jwilder/docker-gen/pull/335

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:17
  • Comments:31 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
wlouckxcommented, May 5, 2021

I’m still having the issue 😕

Some relevant info:

docker inspect nginx-proxy
docker inspect nginx-proxy
[
    {
        "Id": "a0346ea077c1fb3a72211c36bd9c3efc951fdb7206faecca81768b7fcbb8fa1c",
        "Created": "2021-05-05T18:16:13.84677097Z",
        "Path": "/app/docker-entrypoint.sh",
        "Args": [
            "forego",
            "start",
            "-r"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 22424,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2021-05-05T18:16:14.430302245Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:ff7a29a2cd2def6dfd3e878a4123c716e2376131c5293940d6c1a972b95723bc",
        "ResolvConfPath": "/var/lib/docker/containers/a0346ea077c1fb3a72211c36bd9c3efc951fdb7206faecca81768b7fcbb8fa1c/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/a0346ea077c1fb3a72211c36bd9c3efc951fdb7206faecca81768b7fcbb8fa1c/hostname",
        "HostsPath": "/var/lib/docker/containers/a0346ea077c1fb3a72211c36bd9c3efc951fdb7206faecca81768b7fcbb8fa1c/hosts",
        "LogPath": "/var/lib/docker/containers/a0346ea077c1fb3a72211c36bd9c3efc951fdb7206faecca81768b7fcbb8fa1c/a0346ea077c1fb3a72211c36bd9c3efc951fdb7206faecca81768b7fcbb8fa1c-json.log",
        "Name": "/nginx-proxy",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/var/run/docker.sock:/tmp/docker.sock:ro"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "def-network",
            "PortBindings": {
                "443/tcp": [
                    {
                        "HostIp": "127.0.0.1",
                        "HostPort": "443"
                    }
                ],
                "80/tcp": [
                    {
                        "HostIp": "127.0.0.1",
                        "HostPort": "80"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "private",
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": null,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "Mounts": [
            ],
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/dd983bcbb0a498d730dbc36508b71b986086c0a7764811ac21cb9773612a20dd-init/diff:/var/lib/docker/overlay2/efb77533b8800c262b8356b116d7589f29d5145dfd25a839bdf80ab6bcdcff85/diff:/var/lib/docker/overlay2/df4ad48c89e256fccaee8875679818324198fcf6f60731458af80cd3417da85a/diff:/var/lib/docker/overlay2/b26908a42d7e184fcd3588eb73cce4845c269309309adbe5c70ae93efb30be9a/diff:/var/lib/docker/overlay2/b9b6e29d3ffd085229a712459f5c483551d4f300e04f74a5940aacf2071c0f42/diff:/var/lib/docker/overlay2/2fdce0224dc1344de41271996a70d3cd59b6f44a58cd84e6b3ed41f82d6062db/diff:/var/lib/docker/overlay2/3ea2528e1c792f49aea31021db72c5e26bd489470b68d4be96ee7a862ccb8a43/diff:/var/lib/docker/overlay2/d63fc04bce4f6b47387872256886ef4504fa22f67979b29418badf834a0f204f/diff:/var/lib/docker/overlay2/11ce5753c3114f3f264a5f03987c2086580e9a2bbc4566250ad3adc92aca8b9c/diff:/var/lib/docker/overlay2/596801a27596a29cd6f78006a3a283c3ffd55b2d1b7b1902a3e811101e2ce71e/diff:/var/lib/docker/overlay2/407a70cc305a505c8ebe785a70f837a779b00397a11612c41fa8acdde608d50f/diff:/var/lib/docker/overlay2/d2d98f0ec99d089bd1b03ad835f73690717627c661d23f391c3dd9bd5f039d93/diff:/var/lib/docker/overlay2/20215a3a23c3b546c8455fa9ded5307e5ac2b7fd993b4862294ade06b5e67665/diff",
                "MergedDir": "/var/lib/docker/overlay2/dd983bcbb0a498d730dbc36508b71b986086c0a7764811ac21cb9773612a20dd/merged",
                "UpperDir": "/var/lib/docker/overlay2/dd983bcbb0a498d730dbc36508b71b986086c0a7764811ac21cb9773612a20dd/diff",
                "WorkDir": "/var/lib/docker/overlay2/dd983bcbb0a498d730dbc36508b71b986086c0a7764811ac21cb9773612a20dd/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/var/run/docker.sock",
                "Destination": "/tmp/docker.sock",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Type": "volume",
                "Name": "a1a79020c85ca775ba26a1e166a5ae07062eb20799de12ffa959d8419e2234db",
                "Source": "/var/lib/docker/volumes/a1a79020c85ca775ba26a1e166a5ae07062eb20799de12ffa959d8419e2234db/_data",
                "Destination": "/etc/nginx/certs",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Type": "volume",
                "Name": "b816bddd890bdb690ca67e0aca91eed203fc3896333ede2f91c8f862f6b4c339",
                "Source": "/var/lib/docker/volumes/b816bddd890bdb690ca67e0aca91eed203fc3896333ede2f91c8f862f6b4c339/_data",
                "Destination": "/etc/nginx/dhparam",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],
        "Config": {
            "Hostname": "nginx-proxy",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "443/tcp": {},
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NGINX_VERSION=1.19.10",
                "NJS_VERSION=0.5.3",
                "PKG_RELEASE=1~buster",
                "DOCKER_GEN_VERSION=0.7.6",
                "DOCKER_HOST=unix:///tmp/docker.sock"
            ],
            "Cmd": [
                "forego",
                "start",
                "-r"
            ],
            "Image": "jwilder/nginx-proxy",
            "Volumes": {
                "/etc/nginx/certs": {},
                "/etc/nginx/dhparam": {},
                "/tmp/docker.sock": {}
            },
            "WorkingDir": "/app",
            "Entrypoint": [
                "/app/docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "1d9c843b67e0c8f9a7f85c1bf8329a0a3832707915ea39c310cd2bd9287a90fe",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "def",
                "com.docker.compose.project.config_files": "docker-compose.yml",
                "com.docker.compose.project.working_dir": "/mnt/shared/home/Workspaces/environment/def",
                "com.docker.compose.service": "nginx-proxy",
                "com.docker.compose.version": "1.29.1",
                "maintainer": "Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag)",
                "org.opencontainers.image.created": "2021-05-03T00:02:36.782Z",
                "org.opencontainers.image.description": "Automated nginx proxy for Docker containers using docker-gen",
                "org.opencontainers.image.licenses": "MIT",
                "org.opencontainers.image.revision": "09d30cf1a60f9e6edbd741819ab73e64397e7f9e",
                "org.opencontainers.image.source": "https://github.com/nginx-proxy/nginx-proxy",
                "org.opencontainers.image.title": "nginx-proxy",
                "org.opencontainers.image.url": "https://github.com/nginx-proxy/nginx-proxy",
                "org.opencontainers.image.version": "latest"
            },
            "StopSignal": "SIGQUIT"
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "f884d275670b564d7aad7c5178aa21fe2eed75f74bbe8b24c0c9475edbbad42c",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "443/tcp": [
                    {
                        "HostIp": "127.0.0.1",
                        "HostPort": "443"
                    }
                ],
                "80/tcp": [
                    {
                        "HostIp": "127.0.0.1",
                        "HostPort": "80"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/f884d275670b",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "def-network": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "nginx-proxy",
                        "a0346ea077c1"
                    ],
                    "NetworkID": "b9767f6bbcb333bf06018687715d98d26b0e2df66ffdfdbfebc7cb7fc9fec161",
                    "EndpointID": "c628e8cdabfad5b82d09b85bfabc6fa3f6375c7dc4561249db7e8f896e644078",
                    "Gateway": "182.18.20.1",
                    "IPAddress": "182.18.20.3",
                    "IPPrefixLen": 24,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:b6:12:14:03",
                    "DriverOpts": null
                }
            }
        }
    }
]

Docker version:

Client:
 Version:           20.10.6
 API version:       1.41
 Go version:        go1.16.3
 Git commit:        370c28948e
 Built:             Mon Apr 12 14:10:41 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.3
  Git commit:       8728dd246c
  Built:            Mon Apr 12 14:10:25 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.5.0
  GitCommit:        8c906ff108ac28da23f69cc7b74f8e7a470d1df0.m
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
Docker compose example:
version: '3.5'

networks:
    def-network:
        name: 'def-network'
        driver: bridge
        driver_opts:
            com.docker.network.enable_ipv6: "false"
        ipam:
            driver: default
            config:
                - subnet: 182.18.20.0/24

services:
    nginx-proxy:
        container_name: nginx-proxy
        hostname: nginx-proxy
        image: jwilder/nginx-proxy
        ports:
            - "127.0.0.1:80:80"
            - "127.0.0.1:443:443"
        volumes:
            - /var/run/docker.sock:/tmp/docker.sock:ro
        networks:
            def-network:

    ansible:
        container_name: ansible
        image: ansible/ansible-runner
        command: ["/ansible/run.sh"]
        tty: true
        networks:
            def-network:
        restart: on-failure
        secrets:
            - ssl_private_key
            - ssl_public_key
            - ssh_private_key
            - ssh_public_key
        volumes:
            - ./ansible:/ansible
            - ./shared-config/ssh/id_rsa:/ansible/env/ssh_key

    admin:
        container_name: admin.127.0.0.1.nip.io
        hostname: admin
        domainname: '127.0.0.1.nip.io'
        depends_on:
            - nginx-proxy
        entrypoint: /start/entrypoint.sh
        environment:
            VIRTUAL_HOST: 'admin.127.0.0.1.nip.io'
            DOMAIN: '127.0.0.1.nip.io'
        image: registry.local.test/ops/auth/admin:v4
        networks:
           def-network:
        tty: true
        working_dir: /var/www/admin
        volumes:
            # Ansible SSH connection
            - ./shared-config/ssh/id_rsa.pub:/root/.ssh/authorized_keys
            # Application
            - ./projects/ops/auth/admin:/var/www/admin
            - ./scripts/ops/auth/admin:/start

    auth:
        container_name: auth.127.0.0.1.nip.io
        hostname: auth
        domainname: '127.0.0.1.nip.io'
        depends_on:
            - nginx-proxy
            - admin
        entrypoint: /start/entrypoint.sh
        environment:
            VIRTUAL_HOST: 'auth.127.0.0.1.nip.io'
            DOMAIN: '127.0.0.1.nip.io'
        image: registry.local.test/ops/auth/auth:v1
        networks:
            def-network:
        tty: true
        working_dir: /var/www/auth
        volumes:
            # Ansible SSH connection
            - ./shared-config/ssh/id_rsa.pub:/root/.ssh/authorized_keys
            # Application
            - ./projects/ops/auth/auth:/var/www/auth
            - ./scripts/ops/auth/auth:/start
2reactions
daisukixcicommented, Apr 8, 2021

I have the same issue and tried the fix by building myself the following image for the proxy (I changed the DOCKER_GEN_VERSION=0.7.5 to match the last tagged version which looks like embed the patch supposed to fix ):

# setup build arguments for version of dependencies to use
ARG DOCKER_GEN_VERSION=0.7.5
ARG FOREGO_VERSION=0.16.1

# Use a specific version of golang to build both binaries
FROM golang:1.15.10 as gobuilder

# Build docker-gen from scratch
FROM gobuilder as dockergen

# Download the sources for the given version
ARG DOCKER_GEN_VERSION
ADD https://github.com/jwilder/docker-gen/archive/${DOCKER_GEN_VERSION}.tar.gz sources.tar.gz

# Move the sources into the right directory
RUN tar -xzf sources.tar.gz && \
   mkdir -p /go/src/github.com/jwilder/ && \
   mv docker-gen-* /go/src/github.com/jwilder/docker-gen

# Install the dependencies and make the docker-gen executable
WORKDIR /go/src/github.com/jwilder/docker-gen
RUN go get -v ./... && \
   CGO_ENABLED=0 GOOS=linux go build -ldflags "-X main.buildVersion=${DOCKER_GEN_VERSION}" ./cmd/docker-gen

# Build forego from scratch
# Because this relies on golang workspaces, we need to use go < 1.8.
FROM gobuilder as forego

# Download the sources for the given version
ARG FOREGO_VERSION
ADD https://github.com/jwilder/forego/archive/v${FOREGO_VERSION}.tar.gz sources.tar.gz

# Move the sources into the right directory
RUN tar -xzf sources.tar.gz && \
   mkdir -p /go/src/github.com/ddollar/ && \
   mv forego-* /go/src/github.com/ddollar/forego

# Install the dependencies and make the forego executable
WORKDIR /go/src/github.com/ddollar/forego/
RUN go get -v ./... && \
   CGO_ENABLED=0 GOOS=linux go build -o forego .

# Build the final image
FROM nginx:1.19.3
LABEL maintainer="Jason Wilder mail@jasonwilder.com"

# Install wget and install/updates certificates
RUN apt-get update \
 && apt-get install -y -q --no-install-recommends \
    ca-certificates \
    wget \
 && apt-get clean \
 && rm -r /var/lib/apt/lists/*


# Configure Nginx and apply fix for very long server names
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
 && sed -i 's/worker_processes  1/worker_processes  auto/' /etc/nginx/nginx.conf

# Install Forego + docker-gen
COPY --from=forego /go/src/github.com/ddollar/forego/forego /usr/local/bin/forego
COPY --from=dockergen /go/src/github.com/jwilder/docker-gen/docker-gen /usr/local/bin/docker-gen

# Add DOCKER_GEN_VERSION environment variable
# Because some external projects rely on it
ARG DOCKER_GEN_VERSION
ENV DOCKER_GEN_VERSION=${DOCKER_GEN_VERSION}

COPY network_internal.conf /etc/nginx/

COPY . /app/
WORKDIR /app/

ENV DOCKER_HOST unix:///tmp/docker.sock

VOLUME ["/etc/nginx/certs", "/etc/nginx/dhparam"]

ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD ["forego", "start", "-r"]

But got the same upstream error Here is my docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-tp-docker)

Server:
 Containers: 10
  Running: 5
  Paused: 0
  Stopped: 5
 Images: 31
 Server Version: 20.10.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: active
  NodeID: REDACTED
  Is Manager: true
  ClusterID: REDACTED
  Managers: 1
  Nodes: 1
  Default Address Pool: 10.0.0.0/8
  SubnetSize: 24
  Data Path Port: 4789
  Orchestration:
   Task History Retention Limit: 5
  Raft:
   Snapshot Interval: 10000
   Number of Old Snapshots to Retain: 0
   Heartbeat Tick: 1
   Election Tick: 10
  Dispatcher:
   Heartbeat Period: 5 seconds
  CA Configuration:
   Expiry Duration: 3 months
   Force Rotate: 0
  Autolock Managers: false
  Root Rotation In Progress: false
  Node Address: REDACTED
  Manager Addresses:
   REDACTED
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e.m
 runc version: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.11.11-arch1-1
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.59GiB
 Name: REDACTED
 ID: XB5C:65VO:KHNJ:DLXF:NGS2:LDHI:HX34:EOJW:PWSZ:IURK:UKSW:WFCJ
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: Support for cgroup v2 is experimental

EDIT: It looks like the upstream in default.conf is indeed empty where I run it locally it’s filled, so maybe linked to Arch/Docker swarm

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS ECS jwilder/nginx-proxy fails to generate servers inside ...
Firstly, it's a good idea to avoid using domain names within your Nginx config, especially when defining upstream servers.
Read more >
Avoiding the Top 10 NGINX Configuration Mistakes
Mistake 3: Not Enabling Keepalive Connections to Upstream Servers. By default, NGINX opens a new connection to an upstream (backend) server for ...
Read more >
Docker nginx: [emerg] host not found in upstream “web:3000”
I released my reactJs application. I have code information as below. But I get the error “11 # 11: host not found in...
Read more >
How to configure load balancing using Nginx - UpCloud
sudo mv /etc/nginx/conf.d/default.conf ... upstream backend { least_conn; server 10.1.0.101; server 10.1.0.102; server 10.1.0.103; }.
Read more >
Docker compose : Nginx reverse proxy with multiple containers
A reverse proxy is a server that sits between internal applications and external ... default.conf /etc/nginx/conf.d/default.conf # NOT FOUND response COPY .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found