Skip to content

[Bug]: IP address exhaustion with container delete --force #1378

@thomasjm

Description

@thomasjm

I have done the following

  • I have searched the existing issues
  • If possible, I've reproduced the issue using the 'main' branch of this project

Steps to reproduce

If you create containers and then delete them with --force, it seems to leak IP addresses. Eventually you will reach a state where you can't create a new container, with the error "no free indices are available for allocation". Looking through the code, I found this comes from the IP address allocation logic.

I wrote a test script that will create a simple container and then container delete --force it in a loop. You can find it here:

https://gist.github.com/thomasjm/6a2d60e3233fa55bc7765c2426784b33#file-test_ip_exhaustion-sh

There's also another version that does a graceful shutdown, calling container stop and waiting for the container to fully stop before deleting it:

https://gist.github.com/thomasjm/6a2d60e3233fa55bc7765c2426784b33#file-test_ip_exhaustion_graceful-sh

Current behavior

Running the first script will eventually start generating failures after about ~255 iterations. (Because the default system subnet is a /24, so that's how many IP addresses are available.)

...
ip-leak-test-263
  [263] ip-leak-test-263 -> 192.168.64.180/24
ip-leak-test-264
  [264] ip-leak-test-264 -> 192.168.64.191/24
ip-leak-test-265
  [265] ip-leak-test-265 -> 192.168.64.242/24
FAILED at iteration 266: Error: failed to bootstrap container (cause: "unknown: "no free indices are available for allocation"")

Running the graceful shutdown version of the script does not result in failures.

Expected behavior

IP addresses shouldn't leak; creating a container should always succeed if there are <255 currently running containers. (Or whatever the size of the default subnet is.)

Environment

- OS: Version 26.3.1 (a) (25D771280a)
- Xcode: 
- Container: container CLI version 0.10.0 (build: release, commit: 6bdb647)

Relevant log output

N/A

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

networkIssues and features associated with networking and DNS.

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions