u84six
u84six

Reputation: 4941

'docker-compose up' says that image already exists after delete

I'm trying to start from a clean slate with images that 'docker-compose up' pulls down and runs. So I tried running these docker commands to clean up:

docker rmi $(docker images -aq)
docker rm $(docker ps -aq) -f
docker system prune --all

But when I run docker-compose -f my-yaml-file.yaml up, the console shows:

Pulling shell <repo info>
1.0: Pulling from <repo info>...
ae79f2514705: Already exists
5ad56d5fc149: Already exists
170e558760e8: Already exists
395460e233f5: Already exists
6f01dc62e444: Already exists
1b19c959c7bd: Pull complete

I left out the private repo info above, but wondering why it's saying that these hashes (or whatever they are) already exist. I've tried to delete everything using the commands but no matter what I try, it always detects that something exists. What is it detecting and how to I remove them? I've tried restarting docker, rebooting, etc. It's always the same result.

Upvotes: 1

Views: 4284

Answers (1)

namokarm
namokarm

Reputation: 678

The "problem" is in docker's cache. What you want to do is add a --no-cache flag to your docker compose build command, for more details see docs.

I've also found a github issue, asking for the --no-cache option (that existed already) but in the comments you can see the example for a clean rebuild, where some say the --force-recreate flag is not needed.

 docker-compose rm --all &&
 docker-compose pull &&
 docker-compose build --no-cache &&
 docker-compose up -d --force-recreate &&

I hope this helps!

Upvotes: 1

Related Questions