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

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

client = docker.DockerClient(base_url=dockerConfig.url, version='auto')

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.remove(, 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/", line 261, in _raise_for_status
  File "/lib/python3.6/site-packages/requests/", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/lib/python3.6/site-packages/ecr_copier/", line 58, in replicate_image
    client.images.remove(, force=True)
  File "/lib/python3.6/site-packages/docker/models/", line 462, in remove
    self.client.api.remove_image(*args, **kwargs)
  File "/lib/python3.6/site-packages/docker/utils/", line 19, in wrapped
    return f(self, resource_id, *args, **kwargs)
  File "//lib/python3.6/site-packages/docker/api/", line 494, in remove_image
    return self._result(res, True)
  File "/lib/python3.6/site-packages/docker/api/", line 267, in _result
  File "/lib/python3.6/site-packages/docker/api/", line 263, in _raise_for_status
    raise create_api_error_from_http_exception(e)
  File "/lib/python3.6/site-packages/docker/", 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

Answer questions shin-

That's an error at the server level (in the Docker daemon) - the SDK is behaving appropriately here by raising.

Related questions

docker.errors.DockerException: Error while fetching server API version: Timeout value connect was Timeout(connect=60, read=60, total=None), but it must be an int or float. hot 44
pip install in virtualenv breaks virtualenv hot 42
AttributeError: 'module' object has no attribute 'PY34' hot 39
pip install in virtualenv breaks virtualenv hot 34
'ImportError: No module named ssl_match_hostname' upon 'import docker' in a Python script hot 30
Not compatible with pywin32 version 225 hot 18
docker client on Python 3.8 is not working hot 11
TypeError: load_config() got an unexpected keyword argument 'config_dict' hot 7
Issue with creating a docker container while inside a docker container hot 7
docker client on Python 3.8 is not working hot 7
"addgroup: The GID `20' is already in use." when running `make docs`
build function gives broken pipe error
ResourceWarning: unclosed <socket.socket>
How to create a mount point in a docker container. hot 4
Support for stacks hot 4
Github User Rank List