In every tutorial I've found regarding Docker registry there is a command like this:
docker run -d -p 5000:5000 --name registry registry:2
Tag 2 is used here. Why? I've tried registry without the tag and it also worked. I think it has something to do with different API (?) of Docker registry but I am not sure.
Yes, you are correct! the tag 2 represents Docker Registry v2 Implementation which is also Docker Registry HTTP API V2. which solves several problems that were in V1 and introduce new features as described in the following links:
By removing 2 then docker goes to a default tag called latest which currently points to the following tags 2.7.1, 2.7, 2.
So when Docker Inc. releases Registry V3, the latest tag will point to V3 and in case you need V2 in specific you have to add it to your command explicitly. You can check the available tags for the registry image
You are right about the API. From github.com/docker/distribution:
Distribution
The Docker toolset to pack, ship, store, and deliver content.
This repository's main product is the Docker Registry 2.0 implementation for storing and distributing Docker images. It supersedes the docker/docker-registry project with a new API design, focused around security and performance.
and:
registry
An implementation of the Docker Registry HTTP API V2 for use with docker 1.6+.
When you docker pull registry you actually pull registry:latest and it has the same digest as registry:2. Demo:
$ docker pull registry
Using default tag: latest
latest: Pulling from library/registry
169185f82c45: Already exists
046e2d030894: Pull complete
188836fddeeb: Pull complete
832744537747: Pull complete
7ceea07e80be: Pull complete
Digest: sha256:870474507964d8e7d8c3b53bcfa738e3356d2747a42adad26d0d81ef4479eb1b
Status: Downloaded newer image for registry:latest
$ docker pull registry:2
2: Pulling from library/registry
Digest: sha256:870474507964d8e7d8c3b53bcfa738e3356d2747a42adad26d0d81ef4479eb1b
Status: Downloaded newer image for registry:2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With