For the purpose of matching request ip to its swarm container, add the option to look for the container in the inspect JSON for swarm bridge network. See corresponding issue https://github.com/lyft/metadataproxy/issues/102.
Changes
Add environment variable DOCKER_NETWORK. The variable gives the name of the docker network to use to match request ip to its container.
Method roles.find_container_by_network(ip, network_name) that returns either the container corresponding to ip or None.
Apply previous method to container lookup in roles.find_container(ip).
Tests
Tested in swarm node by running my-swarm-container-that-asks-for-a-role and running metadataproxy-container in the following way:
For the purpose of matching request ip to its swarm container, add the option to look for the container in the inspect JSON for swarm bridge network. See corresponding issue https://github.com/lyft/metadataproxy/issues/102.
Changes
DOCKER_NETWORK
. The variable gives the name of the docker network to use to match request ip to its container.roles.find_container_by_network(ip, network_name)
that returns either the container corresponding toip
orNone
.roles.find_container(ip)
.Tests
Tested in swarm node by running
my-swarm-container-that-asks-for-a-role
and runningmetadataproxy-container
in the following way: