-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Description
docker network connect
exposes a --driver-opt
commandline option to pass per-container options to the (eventually custom) libnetwork driver.
While docker network create --opt <key>=<value>
is perfectly mapped the docker-compose equivalent
networks:
mynet:
driver: some-custom-libnetwork-driver-plugin
driver_opts:
some.key: value
I can't find the compose equivalent for per-container options, something like :
services:
myservice:
...
networks:
mynet:
driver_opts:
some.container.specific.key: "value_for_myservice"
Implications of this limitation
In the libnetwork remote driver spec when a container joins a network, the driver is responsible for allocating an IP address during the CreateEndpoint call. It is called with the (randomly generated) NetworkID, the EndpointID and the per-container driver opts and must return an IP address among other things. At this stage, you can't get anything related to the said container's config, so accessing hostname
, container_name
, or any container-related conf that may be useful for the network driver to make its decision about the container's IP (e.g. via a DHCP request or whatever) is impossible. You're left with a meaningless EndpointID you can't map to the container's identity
In a Docker CLI context, you would easily overcome the problem by passing those information via per-container driver_opts flags : docker network connect --driver-opt
.
The absence of such key in the compose file spec prevents per-container custom network config in the docker-compose.yml file, which is sad.
Proposal
Add a driver_opts
key under the services > * > networks > * >
dict and pass them to Docker
I'm open to submitting a PR about that, but let me know if someone else is interested in this feat please.
Activity
stale commentedon Apr 16, 2022
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
stale commentedon Apr 27, 2022
This issue has been automatically closed because it had not recent activity during the stale period.
Per-service network driver_opts
Per-service network driver_opts