【问题标题】:'docker-compose up' says that image already exists after delete'docker-compose up' 表示删除后图像已经存在
【发布时间】:2018-06-18 23:26:59
【问题描述】:

我正在尝试从一个干净的状态开始,使用“docker-compose up”下拉并运行的图像。所以我尝试运行这些 docker 命令来清理:

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

但是当我运行 docker-compose -f my-yaml-file.yaml 时,控制台显示:

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

我忽略了上面的私人回购信息,但想知道为什么说这些哈希(或它们是什么)已经存在。我尝试使用命令删除所有内容,但无论我尝试什么,它总是检测到某些东西存在。它检测到什么以及如何删除它们?我试过重启docker,重启等等,结果总是一样。

【问题讨论】:

  • 使用命令清理图像后,docker images 会返回什么?
  • 必须是基础镜像,比如(ubuntu 什么的)
  • 有一个ubuntu镜像,但是docker控制台说ubuntu上面运行的服务已经存在了。

标签: macos docker docker-compose docker-for-mac


【解决方案1】:

“问题”在 docker 的缓存中。您想要做的是在您的docker compose build 命令中添加一个--no-cache 标志,有关更多详细信息,请参阅docs。

我还找到了一个 github issue,要求 --no-cache 选项(已经存在),但在 cmets 中您可以看到干净重建的示例,其中有人说 --force-recreate 标志不是需要。

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

我希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 2022-01-24
    • 1970-01-01
    • 1970-01-01
    • 2018-12-18
    • 2021-05-18
    • 1970-01-01
    • 1970-01-01
    • 2021-08-22
    • 1970-01-01
    相关资源
    最近更新 更多