Getting the Version of the Latest Release
What’s the latest release of Docker?
Its homepage doesn’t tell you anything. Have to poke around, click on a few links, may or may not get you what you want. If there’s a quick way, even better a CLI method, that will be great.
Couple things we can do. First, when installing docker, we use the URL https://get.docker.com/. It has a path that will return an installation instruction with the version number:
|
|
There is another way. Well, there is always another way. Docker project is hosted in GitHub, we can use this URL:
|
|
which will be redirected to the latest release:
|
|
Since it’s a redirect, we can use HTTP HEAD method without download the entire response body:
|
|
Extract and process the value of the Location
field will get us what we are looking for.
Let’s construct a simple command to obtain such an information:
|
|
or:
|
|
Both commands will return v1.11.2
.
By using GitHub, not only we can get the latest stable release version of Docker, we can also obtain other projects. In fact, if the project was hosted in GitHub, and it was tagged properly with the releases, you can use this method to obtain the version. However, if it’s not properly tagged, such as Node.js, you need to find another way.