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.

How to properly tell nginx-proxy to use bridge from docker-compose?

See original GitHub issue

When I start nginx-proxy using

docker run -d -p 80:80 -p 443:443 -v /var/run/docker.sock:/tmp/docker.sock:ro -v /etc/nginx/certs:/etc/nginx/certs:rw --name nginx-proxy jwilder/nginx-proxy

I see the following network definition for the nginx-proxy container

            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "c3d28dfbcfe6c8a4dd28f5d782c205f3cafdac990bb1d0685d4b62ba28e98a79",
                    "EndpointID": "6b1c06ecae27fd994d2a12b4d8818aa53b90b4153284af9e97e4396644e66445",
                    "Gateway": "172.24.26.1",
                    "IPAddress": "172.24.26.17",
                    "IPPrefixLen": 24,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:18:1a:11"
                }
            }

but if I start docker using docker-compose with the following docker-compose.yml file

version: '2'

services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    restart: always
    mem_limit: 4g
    `ports:`
      - 80:80
      - 443:443
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - /etc/nginx/certs:/etc/nginx/certs

if get the following network definition

            "Networks": {
                "nginxproxy_default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "nginx-proxy",
                        "c091a1b37d8e"
                    ],
                    "NetworkID": "e05cc93cbe94d2bfc2a545df41c490f84be62329736a3ca74fab575ed014379f",
                    "EndpointID": "369993e43d114f2b5763048fc0451671450d8c3d21e93cad2c5428c93a8b5935",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02"
                }
            }

The problem is that all of the currently running containers don’t have a special network definition and everything works just fine so I assume they are all using the bridge network when no configuration is specified and so as soon as I transition nginx-proxy to container and it starts using nginxproxy_default so now all of the containers are not reachable by the nginx-proxy.

I would prefer to have a solution that does not require I modify all of the other containers runtime definition to use a special network, rather I would like to be able to tell nginx-proxy to use the same network definition from docker-compose as it does when it is started using the docker run command above.

How do get nginx-proxy running from a docker-compose file and have it use the same network as it does when run from docker run?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
nosovkcommented, Mar 14, 2017

Hello! I’ve used different approach. I’ve created new external network, not in docker-compose. Just from terminal. docker network create nginx-proxy after I’ve added

networks:
  default:
    external:
      name: nginx-proxy

into the end of each docker-compose.yml

that’s all. docker-compose will use that network like a hub, and everything will work.

0reactions
kingpalethecommented, Apr 16, 2019

Note, this solution also seems to require me to use links so my web container can still find my database container https://docs.docker.com/compose/compose-file/#links

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker compose : Nginx reverse proxy with multiple containers
A reverse proxy is a server that sits between internal applications and external clients, forwarding client requests to the appropriate server.
Read more >
Running an NGINX reverse proxy with Docker and Let's ...
Setting up the reverse proxy ... To have the separate websites respond only to their respective hosts, you use a reverse proxy. This...
Read more >
How to setup the Nginx Proxy Manager Docker example
Ensure Docker and docker-compose are installed · Create a docker-compose file to configure the Nginx Proxy Manager image · Run docker-compose up ...
Read more >
docker compose up nginx reverse proxy not adding containers ...
You can check which network the containers with compose are using with the ... to be in default bridge network , you can...
Read more >
Putting it All Together - How To. - YouTube
In this tutorial, I'll go through the base level of what I use in most of ... Putting it All Together - Docker,...
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