A Docker image contains the code used to create a Docker container, such as creating a Nginx web server, or a mySQL server, or a home grown app, and the list goes on. In this way, an image is like a template used to create a container. An image is kind of like a virtual machine, but much more light weight, using significantly less storage a memory (containers are usually megabytes in size).
There are various ways to pull down an image:
Before pulling down an image, you'll want to use the docker images command to return the list of images that have allready been pulled down, like this.
docker images REPOSITORY TAG IMAGE ID CREATED SIZE foo latest 105b54dc64f1 32 hours ago 196.7 MB
Then, use the docker search command to find the image you want to pull down.
The docker pull command followed by the name of the image pulls down the image. In this example, the "bar" image will be pulled down.
docker pull bar
By default, the latest version of the image will be pulled down. Or, you can explicity include latest.
docker pull bar:latest
Or you can specify a version.
docker pull bar:0.1.2
And you can optionally specify the registry that contains the image.
docker pull registry.example.com/bar:0.1.2
Something like this should be displayed.
Unable to find image 'bar:latest' locally Trying to pull repository docker.io/library/bar ... latest: Pulling from docker.io/library/bar xxxxxxxxxxxxxx: Pull complete xxxxxxxxxxxxxx: Pull complete xxxxxxxxxxxxxx: Pull complete Digest: sha256:xxxxxxxxxxxxxxxxxxxxxxx ...
Reissuing the docker images command should now show that the latest bar image has been pulled down.
docker images REPOSITORY TAG IMAGE ID CREATED SIZE foo latest 105b54dc64f1 32 hours ago 196.7 MB bar latest 95ga44bc5582 2 weeks ago 967 B