Can't remove container if it fails to start using ContainerCollection.run()
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
I'm using the ContainerCollection.run() method to run containers with the SDK but when the container fails to start (due to wrong parameters or misconfiguration on the Docker Desktop) I can't remove the dangling container since it is not returned to the user when the container.start() call raises an APIError nor is removed if I set the remove flag to True.
I would be able to have this container removed if I set the remove flag to True and/or have the container reference returned to the user, enclosed within an exception might be an option.
$ pip freeze | grep docker && python --version && docker version
docker==7.0.0
Python 3.10.14
Client:
Version: 27.2.0
API version: 1.47
Go version: go1.21.13
Git commit: 3ab4256
Built: Tue Aug 27 14:14:45 2024
OS/Arch: darwin/amd64
Context: default
Server: Docker Desktop 4.34.0 (165256)
Engine:
Version: 27.2.0
API version: 1.47 (minimum version 1.24)
Go version: go1.21.13
Git commit: 3ab5c7d
Built: Tue Aug 27 14:15:15 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.7.20
GitCommit: 8fc6bcff51318944179630522a095cc9dbf9f353
runc:
Version: 1.1.13
GitCommit: v1.1.13-0-g58aa920
docker-init:
Version: 0.19.0
GitCommit: de40ad0
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 in docker/models/containers.py at ContainerCollection.run(), especially the container.start() call referenced in the issue. Trace how APIError is handled and how the remove flag is applied when startup fails. Done means a failed start no longer leaves an unwanted container when remove is enabled, or the container reference remains available to the caller as specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100