docker / docker/docker-py

Internal server error ("Device is Busy") for docker client images.remove()

Open
#2,453 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/question level/docker-engine
Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

docker.version
'4.0.2'

I'm having a problem where calls to images.remove() results in an internal server error. I'm using version 4.0.2 of docker-py.

Below is some context to show where I'm calling images.remove(). In the interest of brevity, I'm leaving out some of the variable declarations and helper functions you see referenced below. This is in a script called replicate_image.py.

client = docker.DockerClient(base_url=dockerConfig.url, version='auto')
client.login(
    username=DOCKER_ECR_USER_NAME,
    password=password,
    email=None,
    reauth=True,
    registry=registry)

img = client.images.pull(srcRepoConfig.uri)
dstRepo = dstRepoConfig.repository()
imageTag = srcRepoConfig.image_tag()
img.tag(repository=dstRepo, tag=imageTag)
dstTag = dstRepoConfig.image_tag()
img.tag(repository=dstRepo, tag=dstTag)
client.images.push(repository=dstRepo)
client.images.remove(img.id, force=True)

And here's the stack trace.

2019-10-26 15:55:52,536 :INFO : pushing image to dst repository. uri:<my-ecr-repository>
2019-10-26 15:55:53,318 :INFO : Pushed image successfully. Deleting local copy of image: sha256:
Traceback (most recent call last):
  File "/lib/python3.6/site-packages/docker/api/client.py", line 261, in _raise_for_status
    response.raise_for_status()
  File "/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://127.0.0.1:4243/v1.24/images/sha256:6b65ccc2e1ae6e611880d2b21e94d6ef4c999860ee19a20eebce71297b32100e?force=True&noprune=False

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/lib/python3.6/site-packages/ecr_copier/replicate.py", line 58, in replicate_image
    client.images.remove(img.id, force=True)
  File "/lib/python3.6/site-packages/docker/models/images.py", line 462, in remove
    self.client.api.remove_image(*args, **kwargs)
  File "/lib/python3.6/site-packages/docker/utils/decorators.py", line 19, in wrapped
    return f(self, resource_id, *args, **kwargs)
  File "//lib/python3.6/site-packages/docker/api/image.py", line 494, in remove_image
    return self._result(res, True)
  File "/lib/python3.6/site-packages/docker/api/client.py", line 267, in _result
    self._raise_for_status(response)
  File "/lib/python3.6/site-packages/docker/api/client.py", line 263, in _raise_for_status
    raise create_api_error_from_http_exception(e)
  File "/lib/python3.6/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 500 Server Error: Internal Server Error ("Device is Busy")
Script <my_script> failed with an exit status of 1.

    Failed with exit code 1

Exit Status: 1
 
Signal: 0
 
Core Dumped: 0

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 reproduction in replicate_image.py, focusing on client.images.push() followed by client.images.remove(img.id, force=True). Read docker/models/images.py and docker/api/image.py around remove_image(), then reproduce the 500 response and trace the Docker Engine API behavior. Done means identifying the source of the “Device is Busy” failure and confirming a fix or documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.