Remiser tous les containers inutilisés
Remiser tous les containers inutilisés
Souvent quand on veut supprimer une image Docker, on obtient le message suivant :
➜ kawa ~/Documents/Docker.io/jekyll docker rmi 1a844a4ef377
Error response from daemon: Conflict, cannot delete 1a844a4ef377 because the container 96f6b66c031b is using it, use -f to force
2014/11/22 13:24:18 Error: failed to remove one or more images
En clair on a un ou un « tas » de container Docker toujours liés à l’image. En faisant docker ps
, on remarque qu’il n’y a pas de container en cours d’exécution. En lançant la commande docker ps -a
, on obtient l’ensemble des containers terminés ou pas :
➜ kawa ~/Documents/Docker.io/jekyll docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
96f6b66c031b lamanum_jekyll:latest "/bin/bash" 6 minutes ago Exited (-1) 5 minutes ago compassionate_heisenberg
a85d5ada2c1f lamanum_jekyll:latest "/bin/sh" 6 minutes ago Exited (0) 6 minutes ago evil_euclid
ac2ab419fffb lamanum_jekyll:latest "/bin/bash" 6 minutes ago Exited (0) 6 minutes ago sick_brown
975d005a75ae lamanum_jekyll:latest "jekyll serve --watc 11 minutes ago Exited (0) 10 minutes ago tender_hoover
cf36a4d52f62 lamanum_jekyll:latest "jekyll serve --watc 16 minutes ago Exited (0) 11 minutes ago hungry_feynman
2424c890684d lamanum_jekyll:latest "jekyll build" 16 minutes ago Exited (0) 16 minutes ago focused_hoover
d738098da57e lamanum_jekyll:latest "jekyll serve --watc 17 minutes ago Exited (1) 17 minutes ago jekyll_www_1
98a8be0a11ad lamanum_jekyll:latest "jekyll serve" 26 minutes ago Exited (0) 22 minutes ago pensive_heisenberg
7b7bf19f472c lamanum_jekyll:latest "jekyll build" 26 minutes ago Exited (0) 26 minutes ago mad_perlman
3c8a9694c5ca lamanum_jekyll:latest "jekyll build" 28 minutes ago Exited (0) 28 minutes ago hungry_turing
98be4012d120 lamanum_jekyll:latest "jekyll build" 28 minutes ago Exited (0) 28 minutes ago condescending_darwin
Les containers terminés ont le status Exited
. Pour se débarrasser de ces encombrants, voici la ligne de commande de nettoyage :
➜ kawa ~/Documents/Docker.io/jekyll docker ps -a | awk '/Exited/ { print "docker rm " $1 }' | sh
96f6b66c031b
a85d5ada2c1f
ac2ab419fffb
975d005a75ae
cf36a4d52f62
2424c890684d
d738098da57e
98a8be0a11ad
7b7bf19f472c
3c8a9694c5ca
98be4012d120
Enfin, nous allons pouvoir faire ce que l’on souhaitait faire initialement : supprimer une image Docker.
➜ kawa ~/Documents/Docker.io/jekyll docker rmi 1a844a4ef377
Untagged: lamanum_jekyll:latest
Deleted: 1a844a4ef377075d43bbd2168c0bd304e8d75040eda076c779dbd829a3daac08
Deleted: b0c365b2350e840ddb4302c13c6ecfe218abc39af253025c1093ee57240996cd
Deleted: 227f46ca989815ba813852b80cb6e1740d281d1b7bd54435ce9d1a3659db3527
Deleted: 4981ff94de75781f5a121504cd9bea878913a464b09eecf107afed2d46a605f5
Deleted: c3ce614081bc0653943f194aebe3408045bb45aabf1c49c0cdfdc3d2ac0dfa15
Deleted: 2527ff912575254b5bc53b53306683fb04938e63ca7fd445543d632c79a826dd
Deleted: bbdee5611191bf9448c2306dba760023962078311de3fcbfaf9b4ab186ee29c2
Deleted: c5b66d71c13d047ed3d9969e7246fde8bf1329b2ff9a7300a4e1d2f92c623854
Deleted: 8462c315161f4aaf7dbbfccff47601aa1ef481de3df1a2d94f00daea374e4661
Deleted: 3d91edcad8ddce779e47dc5357237aebbde605f16405cd78a71411d48c758550
Deleted: d10be432e4a2d39a1248a363436a3c27870cb9eda547b0e98ebdbe9c4988e8b4
Et voilà.