Nei nostri tutorial precedenti hai imparato l'installazione del motore Docker sul sistema operativo CentOS/RHEL e Ubuntu e hai estratto le immagini dall'hub Docker. Successivamente ha creato contenitori con immagini. Questo tutorial ti aiuterà a cercare, estrarre, elencare ed eliminare le immagini Docker dal tuo sistema host.
Cerca immagini Docker
Prima di tutto, cerca le immagini del contenitore Docker dall'hub Docker. Ad esempio, il comando seguente cercherà tutte le immagini con Ubuntu e le elencherà come output
# docker search ubuntu
Il risultato apparirà come sotto
NAME DESCRIPTION STARS OFFICIAL AUTOMATED ubuntu Ubuntu is a Deb... 3318 [OK] ubuntu-upstart Upstart is an e... 60 [OK] torusware/speedus-ubuntu Always updated ... 25 [OK] ubuntu-debootstrap debootstrap --v... 24 [OK] rastasheep/ubuntu-sshd Dockerized SSH ... 22 [OK] neurodebian NeuroDebian pro... 17 [OK] nuagebec/ubuntu Simple always u... 4 [OK] nickistre/ubuntu-lamp-wordpress LAMP on Ubuntu ... 4 [OK] nimmis/ubuntu This is a docke... 3 [OK]
Estrai le immagini Docker
Ora estrai l'immagine docker richiesta dall'hub docker sul tuo sistema locale usando i seguenti comandi. Il comando seguente scaricherà l'immagine denominata "ubuntu".
# docker pull ubuntu latest: Pulling from library/ubuntu fa5be2806d4c: Pull complete b4af4261cb15: Downloading [==> ] 3.779 MB/70.55 MB 5d358abc5d9c: Download complete 2933d50b9f77: Download complete
Stiamo anche scaricando centos immagini dall'hub Docker.
# docker pull centos
Elenca immagini Docker
Ora assicurati che le immagini sopra siano state scaricate correttamente sul tuo sistema. Sotto il comando elenca tutte le immagini.
# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu latest 36248ae4a9ac 2 hours ago 188 MB centos latest 2933d50b9f77 2 hours ago 196.6 MB
Rimuovere le immagini Docker
Per rimuovere un'immagine, Docker fornisce rmi opzione. Usando questo possiamo eliminare qualsiasi immagine della finestra mobile dal nostro sistema locale. Ad esempio, usa il comando seguente con la modifica di ID IMMAGINE con il tuo ID immagine Docker.
# docker rmi <IMAGE ID>
oppure puoi semplicemente rimuovere le immagini usando il nome del repository (nome dell'immagine)
# docker rmi ubuntu
Nel caso in cui tu abbia due immagini con lo stesso nome, aggiungi il nome del tag durante la cancellazione
# docker rmi ubuntu:latest