Skip to content

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

Open
@jjbuck

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions