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

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.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 19
  • Comments: 17

Most upvoted comments

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

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.

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

Run docker-compose stop and thendocker-composer rm xyz

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

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.

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).

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’

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

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