mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-02-24 01:38:15 +00:00
fix: Ensure networks are actually connected to pytest container
The `network` object would never be in a list of network names (strings), and without `greedy=True` arg as the `docker-py` API docs note, the containers will not be part of the results, thus always returning an empty list which was not intended.. Now the network will properly match the current networks for pytest container, avoiding duplicate connect attempts, and the network list result will actually have containers to count when filtering by length.
This commit is contained in:
parent
0e5d97a268
commit
04b0181980
@ -367,7 +367,7 @@ def connect_to_network(network):
|
||||
return None
|
||||
|
||||
# make sure our container is connected to the nginx-proxy's network
|
||||
if network not in my_networks:
|
||||
if network.name not in my_networks:
|
||||
logging.info(f"Connecting to docker network: {network.name}")
|
||||
network.connect(my_container)
|
||||
return network
|
||||
@ -405,7 +405,7 @@ def connect_to_all_networks():
|
||||
return []
|
||||
else:
|
||||
# find the list of docker networks
|
||||
networks = [network for network in docker_client.networks.list() if len(network.containers) > 0 and network.name != 'bridge']
|
||||
networks = [network for network in docker_client.networks.list(greedy=True) if len(network.containers) > 0 and network.name != 'bridge']
|
||||
return [connect_to_network(network) for network in networks]
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user