Unable to delete docker image - docker

I am getting the following error when I execute docker image rm -f command and I am not able to delete the docker images from my system even after using force option.Please help to resolve it.Even prune command is also giving the same error.
Error: error reading image "5325e37426255f971e691f20b068b47d71dd3be62bd8bf22c5f6d23964bd4a44" as image: error locating item named "manifest" for image with ID "5325e37426255f971e691f20b068b47d71dd3be62bd8bf22c5f6d23964bd4a44": file does not exist

Related

Error response from daemon: readlink /var/lib/docker/overlay2/l/2U5H3EROYQLCC2NERR6OB7P4U5: invalid argument

I am new to docker and using docker in my server. My server space got filled and after making spaces my docker cant take some command operation for example:
docker inspect image_name
my image is: tbmg.samsmartcrm.com
so when i apply:
docker inspect tbmg.samsmartcrm.com
gives error:
Error response from daemon: readlink /var/lib/docker/overlay2/l/2U5H3EROYQLCC2NERR6OB7P4U5: invalid argument
I ve tried to understand the error but could not able to understand. I have followed other too but they all say remove the image by using prune and rebuild but this will loose all data and settings which i did on that image for my site.
Is there any way to repair the image? using docker.

Is there docker image tagging without dependency in image ID

I have docker environment with multiple tagging.
Like this:
image01:dev - > image01:staging - > image01:Prod
image02:dev - > image01:staging - > image01:Prod
In this case I have to remove one tagged environment, because they use same image ID. How can I change the image ID with tagging?
echo "Docker Compose Down"
docker-compose down
echo "Docker Compose Down ... Complete!"
echo "Docker Images Remove"
docker rmi -f $(docker images -q)
echo "Docker Images Remove ... Done!"
I get these errors:
Error response from daemon: conflict: unable to delete 3637565c5b84 (cannot be forced) - image is being used by running container 67692aab8b26
Error response from daemon: conflict: unable to delete 60892921e72f (cannot be forced) - image is being used by running container 4be9a7ee6d0d
Error response from daemon: conflict: unable to delete 8289f92814de (cannot be forced) - image is being used by running container b06fb2e8b8a8
Error response from daemon: conflict: unable to delete b2c5303a61cb (cannot be forced) - image is being used by running container 550f14f5d8d3
Error response from daemon: conflict: unable to delete db95989f3c68 (cannot be forced) - image is being used by running container 3752ae226b9e
Error response from daemon: conflict: unable to delete 6f2a973fcb00 (cannot be forced) - image is being used by running container e0b92afc05c2
You need to see if you have some container in some state that is currently using these images before deleting it.
docker ps -a
You can see the containers that are not fully stopped and make docker rm with the container Id, then when you finish that process try to delete the images again.
Independently of what containers are running, you can use the docker tag command to assign a tag to a different image.
docker tag image01:dev image01:staging
# Now "dev" and "staging" point at the same image
You then need to stop, delete, and restart containers to run them with the new image
docker stop staging
docker rm staging
docker run --name staging ... image01:staging
This will result in "dangling" images with no tags and no running containers. You can clean these up
docker image prune -f
Note that in many clustered environments the literal name of a tag is an important identifier, and you shouldn't reuse tag names like this. In Kubernetes, for example, it's very easy to trigger a zero-downtime rolling upgrade of a Deployment object, but only if you're changing some textual aspect of the deployment configuration; making it restart a Deployment with a newer version of the same image tag is significantly harder. I'd suggest using a tag name like a source control commit ID or a date stamp and just directly running that
docker run --name staging ... image01:20190610
docker image prune -a will clean up images with tags but no running containers, on the assumption that they can always be rebuilt or pulled again from a repository.

Error response from daemon: conflict: unable to delete 2602b4852593 (cannot be forced) - image has dependent child images

I am unable to delete the docker images. Getting below error.
docker image rm -f $(docker image ls -aq)
Error response from daemon: conflict: unable to delete 6ab53ec1a8c9 (cannot be forced) - image is being used by running container d65f1c6b7982
Error response from daemon: conflict: unable to delete 2602b4852593 (cannot be forced) - image has dependent child images
Docker version:
docker --version
Docker version 17.05.0-ce, build 89658be
The problem
Error response from daemon: conflict: unable to delete 6ab53ec1a8c9 (cannot be forced) - image is being used by running container d65f1c6b798
As the message says you have a container running that uses the image your are trying to delete, thus the error.
You can stop the container and afterwards run the command again, but a better way exists...
A Better Way
docker image rm -f $(docker image ls -aq)
Instead of using the above hack from old days you can use now:
docker image prune -a
The flag -a will remove all unused docker images, meaning that the ones being used by running containers will not be touched, thus this may be what you want to use in order to achieve what your are trying to do.
If you want to only remove dangling images without removing the ones you already have built then run the same command without the -a flag:
docker image prune
The help for it:
docker image prune --help
Usage: docker image prune [OPTIONS]
Remove unused images
Options:
-a, --all Remove all unused images, not just dangling ones
--filter filter Provide filter values (e.g. 'until=<timestamp>')
-f, --force Do not prompt for confirmation
As suggested in this answer you may want to remove all child images, one by one, by running
docker rmi <repo:tag>
However, as suggested in the linked answer, in some cases you may not want to remove the image by specifying the image id that has multiple tags as these may be used by other images.

docker cp to container: file name too long

I am trying to docker cp a directory and everything inside to a container but I am getting this error:
$ docker cp clink 2eca:.
Error response from daemon: Error processing tar file(exit status 1): open /clink/jobs/target/streams/$global/assemblyOption/$global/streams/assembly/82b354e42adbb42665af515b27b02de840e038ee_2df49b1995a6c8135f35e880f8876f7513ab872d_da39a3ee5e6b4b0d3255bfef95601890afd80709/org/scalacheck/ArbitraryArities$$anonfun$arbTuple11$1$$anonfun$apply$99$$anonfun$apply$100$$anonfun$apply$101$$anonfun$apply$102$$anonfun$apply$103$$anonfun$apply$104$$anonfun$apply$105$$anonfun$apply$106$$anonfun$apply$107$$anonfun$apply$108$$anonfun$apply$109.class: file name too long
I am pretty new to docker to I'm not sure why this is happening or how to fix it
Posted issue onto dockers githug:
https://github.com/docker/docker/issues/31353
It is indeed a bug. It doesn't happen on 1.12.2.
Thanks for opening the issue:
https://github.com/docker/docker/issues/31353

Docker container not running

I have created a docker image which is a python script based on a centos image. This image is working in the host system. Then I converted that image in tar.gz format. After that when I imported that tar.gz file into docker host(in a ubuntu system), it is done properly and the docker images list shows me the image listed in there. Then I tried to run the container in interactive mode using the following command:
$docker run -it image_name /bin/bash
it throws the following error:
docker: Error response from daemon: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused \"exec: \\\"/bin/bash\\\": stat /bin/bash: no such file or directory\"\n".
Although docker run -it image_name /bin/bash command is working for all other images in my system. I tried almost all the means, but got no output apart from this error.
docker run -it image_name /bin/sh works for me! (Docker image, like Alpine, does not have /bin/bash).
I've just run into the same issue after updating Docker For Windows. It seems that it corrupted some image layers.
I cleared all the cached containers and images by running:
docker ps -qa|xargs docker rm -f
docker images -q|xargs docker rmi
The last command returned a few errors (some returned images didn't exist anymore).
Then I restarted the service and everything was running again.
I had the same issue, and it got resolved, after following the steps described in this post...
https://www.jamescoyle.net/how-to/1512-export-and-import-a-docker-image-between-nodes
Instead of saving the docker image (I) as .tar and importing, we need to commit the exited container, based on the image (I), as new image (N).
Then save the newly committed image (N) as .tar file, for importing into a new environment.
Hope this helps...

Resources