Fail to assign staticip along with portmapping to container using docker-py
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
Hi,
I have issue and could not find solution regarding this
Use case:
Trying to assign a static ip from a network to a container and same ip has to be used for portmapping to host network
I am able to achieve this from binary but not from docker.py library
docker run -it --name container --net radio --ip 172.21.0.20 -p 192.168.0.13:5554:5554/udp imagename
in code I am creating container
key=("%s/%s" % (self.port,self.protocol))
cportmapping = { key : (self.ip, self.port)} # { '5554/udp' : (192.168.0.13,5554)}
argd['ports']=self.cportmapping
argd['network'] = self.cnetwork (network = radio)
container=self.client.containers.create(self.cimagename,detach=True,**argd)
network.connect(containerid,ipv4_address=self.networkstaticip) (networkstaticip =172.21.0.21)
Even though i have provided a static ip, it wont use this static called using connect(). It only assigns random ip provided from network radio pool. Can someone help me on this
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the container creation and network.connect() calls shown in the issue, comparing their behavior with the docker run command and Docker Engine API networking semantics. Verify how the requested static IPv4 address and host port mapping are represented, and consider the work complete when the container retains 172.21.0.21 while exposing the specified UDP port.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100