docker / docker/docker-py

Support for "ipv4_address" and other parameters in "connect" method of "Network" objects

Open
#1,366 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

level/dockerclient
Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

I am using docker-2.0.0 and the connect method of Network class has some documented parameters such as "ipv4_address" that is not implemented in Network yet. When calling connect with "ipv4_address" argument, this exception is thrown:
TypeError: connect() got an unexpected keyword argument 'ipv4_address'
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/ContainerManager.py", line 178, in create_container
self.test_network.connect(container=container.id, ipv4_address= new_container_ip_address)

I found that the low level API method "connect_container_to_network" this functionality. So the "connect" method of Network class must be changed to use this parameters of low level API. like this:
def connect(self, container, ipv4_address=None, ipv6_address=None, aliases=None, links=None, link_local_ips=None):
"""
Connect a container to this network.

    Args:
        container (str): Container to connect to this network, as either
            an ID, name, or :py:class:`~docker.models.containers.Container`
            object.
        aliases (list): A list of aliases for this endpoint. Names in that
            list can be used within the network to reach the container.
            Defaults to ``None``.
        links (list): A list of links for this endpoint. Containers
            declared in this list will be linkedto this container.
            Defaults to ``None``.
        ipv4_address (str): The IP address of this container on the
            network, using the IPv4 protocol. Defaults to ``None``.
        ipv6_address (str): The IP address of this container on the
            network, using the IPv6 protocol. Defaults to ``None``.
        link_local_ips (list): A list of link-local (IPv4/IPv6) addresses.

    Raises:
        :py:class:`docker.errors.APIError`
            If the server returns an error.
    """
    if isinstance(container, Container):
        container = container.id
    return self.client.api.connect_container_to_network(container, self.id, ipv4_address=ipv4_address, ipv6_address=ipv6_address, aliases=aliases, links=links, link_local_ips=link_local_ips)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Network.connect method and compare its documented parameters with the low-level connect_container_to_network API mentioned in the issue. Verify that the documented address, alias, link, and link-local parameters can be passed through and that connect accepts the example call without the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.