Pulling, scaricare nuove immagini da un repository Docker
Una installazine pulita di Docker non contiene nessuna immagine. In ambiente Linux di solito il repository locale che contiene le immagini si trova sotto /var/lib/docker/<storage-driver>. Il termine tecnico "pulling" indica l'azione di aggiungere una immagine ad un Docker Host, scaricandola da un registry (il più noto è Docker Hub). Per esempio per aggiungere una immagine "RabbitMQ" sul vostro docker locale il comando da lanciare (scaricando da repository hub.docker.com) è:
docker pull rabbitmq:latest
latest: Pulling from library/rabbitmq
5bed26d33875: Already exists
f11b29a9c730: Already exists
930bda195c84: Already exists
78bf9a5ad49e: Already exists
0719cf990071: Pull complete
22082be2bc3e: Pull complete
c2323e1311ab: Pull complete
785decaedbf4: Pull complete
a6e11a8bffca: Pull complete
909784e4ac48: Pull complete
Digest: sha256:3436c45657cc5111cee9fafc68ee836eeb048aeae85ad60c108d9765a0bfe0ea
Status: Downloaded newer image for rabbitmq:latest
docker.io/library/rabbitmq:latest
L'immagine di rabbitmq richiede 10 layers (5bed26d33875, f11b29a9c730 ...) di cui alcuni, come si può vedere, erano già presenti sulla mia macchina e non sono stati scaricati. Per esempio i primi due 5bed26d33875 e f11b29a9c730. Io sto usando un sistema Linux, uno scarico simile su macchina Windows in genere richiederebbe molti più layer.
Se volete controllare che il pulling abbia avuto successo, lanciate il comando per avere l'elenco delle immagini presenti sul vostro Docker.
Come avrete notato, per effettuare un pulling ho bisogno di indicare il nome dell'immagine, nell'esempio sopra "rabbitmq" e (opzionale) un tag, nell'esempio sopra "latest". Nell'articolo dedicato ai image registries & repositories Docker approfondiamo l'argomento.
Ricerca
Il comando di ricerca di immagini all'interno di Docker Hub è:
docker search
Per esempio docker search ubuntu elenca tutte le immagini presenti in Docker Hub he contengano "ubuntu" nel nome, presenti in repository ufficiali e non. Un esempio del risultato:
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Ubuntu is a Debian-based Linux operating sys… 15155 [OK]
websphere-liberty WebSphere Liberty multi-architecture images … 290 [OK]
ubuntu-upstart DEPRECATED, as is Upstart (find other proces… 112 [OK]
neurodebian NeuroDebian provides neuroscience research s… 94 [OK]
ubuntu/nginx Nginx, a high-performance reverse proxy & we… 64
open-liberty Open Liberty multi-architecture images based… 55 [OK]
ubuntu-debootstrap DEPRECATED; use "ubuntu" instead 49 [OK]
ubuntu/apache2 Apache, a secure & extensible open-source HT… 47
ubuntu/squid Squid is a caching proxy for the Web. Long-t… 40
ubuntu/mysql MySQL open source fast, stable, multi-thread… 38
ubuntu/prometheus Prometheus is a systems and service monitori… 32
kasmweb/ubuntu-bionic-desktop Ubuntu productivity desktop for Kasm Workspa… 31
ubuntu/bind9 BIND 9 is a very flexible, full-featured DNS… 30
ubuntu/postgres PostgreSQL is an open source object-relation… 22
ubuntu/redis Redis, an open source key-value store. Long-… 15
ubuntu/kafka Apache Kafka, a distributed event streaming … 13
ubuntu/prometheus-alertmanager Alertmanager handles client alerts from Prom… 8
ubuntu/grafana Grafana, a feature rich metrics dashboard & … 6
ubuntu/memcached Memcached, in-memory keyvalue store for smal… 5
ubuntu/zookeeper ZooKeeper maintains configuration informatio… 5
ubuntu/telegraf Telegraf collects, processes, aggregates & w… 4
ubuntu/dotnet-deps Chiselled Ubuntu for self-contained .NET & A… 4
ubuntu/cortex Cortex provides storage for Prometheus. Long… 3
ubuntu/cassandra Cassandra, an open source NoSQL distributed … 2
ubuntu/loki Grafana Loki, a log aggregation system like … 0
Per ottenere solo repository ufficiali è possibile aggiungere filter "is-official=true". Di defualt vengono mostrarti solo i primi 25 risultati. Usate --limit per aumentare questo limite fino ad un massimo di 100. Un altro filtro utile è --filter "is-automated=true", elenca solo le immagini con build automatiche.