docker(9) docker rmiのための順番
Cコンパイラ3種をdockerで
https://qiita.com/kaizen_nagoya/items/77184cf005490d7579e6
で作った、4種類のimageを消したかった。
$ docker rm $(docker ps -q -a)
8ce700629c9f
75aa2a1ec996
824ddc62ba9d
7ed22f5b2b09
13fabfc90918
e7625c18deeb
c1bfe03b8544
680392f85570
11bdf7c39dda
26c2e8fe4567
d428f9d6ad93
534cab69a26d
5dfe6ebb03c5
950dd20aac72
401a53e44c5d
0c6eccbad4e3
db62fa194342
7aa98d94d8da
f009c4b010d8
6d192b78f957
221034cd78e0
$ docker rmi $(docker images -q)
Untagged: kaizenjapan/basic:latest
Untagged: kaizenjapan/basic@sha256:aea2b047521ab40f6f54b45aa1d24f6a752f161596c6fad65a68bd5e66200784
Deleted: sha256:f104b06410b034c35b3e98e4c507872ac24ea6e9691cfafa2167e565b0886f3f
Deleted: sha256:1c4fed86342d5dbf251cc7573dc605c14b07a85db4ecb0e28e74ab40e1369e77
...
Error response from daemon: conflict: unable to delete 863371d53d45 (must be forced) - image is referenced in multiple repositories
Error response from daemon: conflict: unable to delete 863371d53d45 (must be forced) - image is referenced in multiple repositories
Error response from daemon: conflict: unable to delete 83a10817c894 (cannot be forced) - image has dependent child images
$
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
kaizenjapan/cc3 latest 156eb2d61390 11 minutes ago 1.8GB
kaizenjapan/cc2 latest 3c56251edcf3 About an hour ago 1.5GB
kaizenjapan/cc latest a90480303225 2 hours ago 1.22GB
gcc latest 6808528eb8f5 5 weeks ago 1.15GB
ある特定の順番でないと消せなかった。
$ docker rmi 6808528eb8f5
Error response from daemon: conflict: unable to delete 6808528eb8f5 (cannot be forced) - image has dependent child images
いきなりrmiはだめらしい。
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d7b5a5211451 gcc "/bin/bash" 10 hours ago Up 10 hours inspiring_pike
60c8ebb17fc3 gcc "/bin/bash" 10 hours ago Exited (100) 10 hours ago brave_yonath
ee6c760a634b gcc "/bin/bash" 26 hours ago Exited (0) 10 hours ago awesome_hamilton
b7692fe59523 gcc "/bin/bash" 34 hours ago Exited (0) 26 hours ago
docker rmで順番に
$ docker rm b7692fe59523
b7692fe59523
$ docker rm ee6c760a634b
ee6c760a634b
$ docker rm 60c8ebb17fc3
60c8ebb17fc3
$ docker rm d7b5a5211451
Error response from daemon: You cannot remove a running container d7b5a52114515799bb2520a2d86a58f764b0234748078f0035baccea579039e1. Stop the container before attempting removal or force remove
まだ1つimageがうごいたままだった。exitでdockerを終了した。
$ docker rm d7b5a5211451
d7b5a5211451
OgawaKiyoshi-no-MacBook-Pro:scripts ogawakiyoshi$ docker rmi 6808528eb8f5
Error response from daemon: conflict: unable to delete 6808528eb8f5 (cannot be forced) - image has dependent child images
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
imageの依存関係の順番に消さないとだめみたい。
$ docker rmi a90480303225
Untagged: kaizenjapan/cc:latest
Untagged: kaizenjapan/cc@sha256:3d355b1ff36a163347e11717d7852e6fe352b746c85fb9ffee072e3b072a7e2a
Deleted: sha256:a90480303225d3f142629ddd7b455ddf7c6476891b64558b34a6a1290dfa5ec0
Deleted: sha256:36140b71eeea321bbe25a30f132ecb102ba350babfae6134b3d104c33ba64a74
$ docker rmi 156eb2d61390
Untagged: kaizenjapan/cc3:latest
Untagged: kaizenjapan/cc3@sha256:acbf6c21c9c52ad15aefd8210128f736b021f76c09aee3ac82c3352e209d14b2
Deleted: sha256:156eb2d613901e433e0f93f8981dbd2042dee8d2a1fe7c01d7b6af950a8d7dd1
Deleted: sha256:2331bad2f22da4ae7dc7494fa16d66abb642ade9674c25d5995913f5fabd508b
$ docker rmi 6808528eb8f5
Error response from daemon: conflict: unable to delete 6808528eb8f5 (cannot be forced) - image has dependent child images
必ずしも、逆順でなくてもいいらしい。なぜなら、一つのコンテナ以外は、すべてgccのものを継承していたから。作成過程の途中の状態の記録があれば分かる。結果だけだとわからない。
$ docker rmi 3c56251edcf3
Untagged: kaizenjapan/cc2:latest
Untagged: kaizenjapan/cc2@sha256:727a003f21e2fd2c1a58fba768c14e7efa081c20187e9be3ce07baa425496c9d
Deleted: sha256:3c56251edcf3deae6a149cf34392a96ec478c1d5c2d089ad4fa50ea756ac65bc
Deleted: sha256:54de2371d4253dfff3b3eb2ecfb5ab115884248b66e62f8667c7fcc6f28ed52e
$ docker rmi 6808528eb8f5
Untagged: gcc:latest
Untagged: gcc@sha256:87d0585f5d309a641775563417a84f251eda7c89c6ae26b96eeb475a57094ea6
Deleted: sha256:6808528eb8f548ef57253da950886c323c8a1abbd608e704af95acf86076f9b9
Deleted: sha256:91275a663eab3efc36aeeb1a4c11c8e5ea540c4afe1cc36a49c29ae80cbc6176
Deleted: sha256:e8fd0a3292093fcab884558f5edbd5656c883f9a635537eec75fa684b10af60a
Deleted: sha256:238d0544066a6f07a184a68de1c797f079d892c7c6eede70174598e76966b3a7
Deleted: sha256:4003a4c823047d89f09c6a0bf5959188211fc70b110a8d4d9a04730c169d3550
Deleted: sha256:09798890afdc89e906b235b5eb538dd1c03e3a86ce799371ce5d2f7fb6a34951
Deleted: sha256:cfac9ecfbc0042ad5d839aff41adba39d65684c7e15af9f66d237dc03d1fd60b
Deleted: sha256:f352c02ab6c1704fd1cac057d122c71ab8d059dcbf433068ad7c88c6d7771a43
Deleted: sha256:b9c3b217e735278337071985f35849d0864facfcc5d01884910980b895e03f77
Deleted: sha256:fbb641a8b94349e89886f65d79928e4673530e2a2b4d33c2c95e0426713f78e4
無事、全部消えた。
参考資料(reference)
コマンドでDockerコンテナを停止・削除、イメージの削除をする
https://qiita.com/shisama/items/48e2eaf1dc356568b0d7
文書履歴(document history)
ver. 0.01 初稿 20190504 夕
ver. 0.02 はてな追記 20190504 夜
ver. 0.03 一括削除 20210505
Author And Source
この問題について(docker(9) docker rmiのための順番), 我々は、より多くの情報をここで見つけました https://qiita.com/kaizen_nagoya/items/0bc05d08cf18af4a8801著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .