Compose: Deleting an image built by docker-compose results in "No such image" error on next run

Created on 13 Mar 2015  路  17Comments  路  Source: docker/compose

Creating an image with docker-compose up and shutting it down and subsequently deleting the underlying image results in next docker-compose up command erroring out with "No such image" error.

Steps to reproduce:

  • checkout https://github.com/toli/metc-docker, it's a Docker Compose setup with some bins and 2 underlying dependencies
  • run it with docker-compose up
  • Stop it
  • Remove the top-level built image with docker rm -f metcdocker_metc
  • Run docker-compose up again
    You will see the error:
metc-docker> docker-compose up
Recreating metcdocker_mysql_1...
Recreating metcdocker_metc_1...
No such image: 19b5e447fe00 (tag: latest)

The referenced image was the first of deleted images:

toli@toli-docker:~/dev/marketcetera/metc-docker> docker rmi -f 19b5e447fe00
Untagged: metcdocker_metc:latest
Deleted: 19b5e447fe007b86dba74fd35b03d2ca4e12afbbad509274476ff907e7f96499
.....
toli:~/metc-docker> docker-compose up
Recreating metcdocker_mysql_1...
Recreating metcdocker_metc_1...
No such image: 19b5e447fe00 (tag: latest)

And the way to fix it is to run docker ps -a and delete the reference to the container that used that image

toli@toli:~/metc-docker> docker ps -a
CONTAINER ID        IMAGE                                COMMAND                CREATED             STATUS                        PORTS                    NAMES
154b0e044fc4        19b5e447fe00                         "/bin/sh -c ./start-   19 minutes ago      Exited (137) 18 minutes ago                            metcdocker_metc_1

toli@toli:~/metc-docker>docker rm 154b0e044fc4
154b0e044fc4

Even though the container has exited, it still seems to be referencing deleted image.
Running docker-container up again works after deleting the already-deleted image.

Most helpful comment

I am still running into this issue
I am using Docker version 1.9.1, build a34a1d5

I had to run docker-compose rm and then docker-compose up before it would work correctly

All 17 comments

This will be fixed by #874, the image is only used for the intermediate

Going to close this issue, please follow along in #874 for the fix

I am still running into this issue
I am using Docker version 1.9.1, build a34a1d5

I had to run docker-compose rm and then docker-compose up before it would work correctly

I ran into this issue as well @justechn suggestion worked for me as well.

Same, I am running into the same issue.

Docker version: 1.10.0, build 590d5108
Docker compose version: 1.6.0, build d99cad6

And running docker-compose rm then docker-compose up fixes the issue as @justechn suggested.

Same here.
Docker version 1.10.2, build c3959b1
docker-compose version 1.6.0, build d99cad6

It happend after I did docker rmi on all images, because the "no space left on device" error appeared:
http://stackoverflow.com/questions/30604846/docker-error-no-space-left-on-device

Deleting all images is a bad idea. If you need to recover from this state you should be able to docker-compose rm to remove the containers which expect the image to exist. However note that you will lose any data volumes by doing this.

Instead of removing all images, I would suggest using something like https://github.com/yelp/docker-custodian to remove the oldest unused images (and containers).

Run docker-compose stop and thendocker-composer rm xyz

# Example
$ docker-compose rm nginx
# From docker-compose.yml file
# xyz:
#  image: nginx:latest

Removed old image and encountered the same issue today. Removing all containers helped.

Just ran into this issue. I had not space on my system so decided to remove all the images forcefully.

Same problem
ERROR: for ### b'No such image: sha256:6e3ba2ac39dbca779294b29cb7e70dbca9b7346a8072e57eb9c67dec9410857f'

Got the same problem. Removed all images and some of them throw this error when doing docker-compose up again.

As it was said before, you could use docker-compose rm and then use docker-compose up again.

Feature request:

Provide a command which removes old unused images.

Why?

Right now I need to use the above statement which is not standard documentation and need to read that used "docker rmi" is a bad idea (see above).

I believe it's not good to have a backlog of images which never will be used again. I use Docker 17.07 and run into this problem again.

Wasted an hour on this issue (using most recent docker-compose version 1.16.1, build 6d1ac21) and was hoping the tool would better handle this situation/issue from two years ago.

Still evaluating PyCharm... same issue :(
Docker version 17.04.0-ce, build 4845c56
PyCharm 2017.2.4
Build #PY-172.4343.24, built on October 19, 2017
Licensed to PyCharm Evaluator
Expiration date: December 10, 2017
JRE: 1.8.0_152-release-915-b12 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.4.0-98-generic

Same issues here, removing all the images and then starting docker-compose up results into the same error:

ERROR: for zookeeper b'no such image: sha256:7d8fb327b1f68c58da35fb0b8094ef003437c477371f0051ed0d98d17e5294bd: No such image: sha256:7d8fb327b1f68c58da35fb0b8094ef003437c477371f0051ed0d98d17e5294bd'

Was this page helpful?
0 / 5 - 0 ratings