containers.run with remove=True sometimes fails to remove the container
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 experiencing this on Windows using Windows containers. The container runs fine and ends normally, but then occasionally the container.remove fails because docker is still writing to the log file while it's trying to remove the container. I suspect that the container isn't entirely stopped. I've worked around it by running containers.prune after containers.run completes. Here's an example of the exception I'm seeing thrown:
docker.errors.APIError: 500 Server Error for http+docker://localnpipe/v1.40/containers/d7c806a817f09b0b4838483d3f3a5137c9883efac332feef4901f1b196f26657?v=False&link=False&force=False: Internal Server Error ("unable to remove filesystem for
d7c806a817f09b0b4838483d3f3a5137c9883efac332feef4901f1b196f26657: remove C:\ProgramData\docker\containers\d7c806a817f09b0b4838483d3f3a5137c9883efac332feef4901f1b196f26657\d7c806a817f09b0b4838483d3f3a5137c9883efac332feef4901f1b196f26657-json.log: The process cannot access the file because it is being used by another process.")
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 by tracing the containers.run path when remove=True, including the subsequent container.remove call, and compare it with the reported containers.prune workaround. Reproduce the Windows-container case and inspect the Docker Engine API behavior around log-file access. Done means containers.run reliably removes the container after normal completion without the reported file-in-use error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100