There are tons of pre-built Docker Images that you can find on Docker’s official repository called DockerHub. In fact, you can also push your own customized Image on DockerHub. These Images can then be pulled using the Docker pull command and can be used as Base Images. In this article, we will discuss how you can search a Docker Image on DockerHub through Command Line Interface.
Note that in order to access DockerHub, you would need a DockerHub account and then you would have to log in to the DockerHub using your command line. You can do so by using the docker login command and then entering relevant details.
1. The Docker Search Command
The general syntax of a Docker Search command is –
sudo docker search <image-name>
For example, if you want to search Ubuntu images, you can use the following command.
sudo docker search ubuntu
The above command returns a list of images with similar names. It returns a list of images with parameters such as the Image name, the automated parameter suggests that you can build the Image automatically using platforms such as Github, etc. The Description parameter describes general information about the Image. The stars parameter displays the ratings given to it by the users and the official parameter suggests whether the Image is official or not.
2. Filtering the Search on the Basis of Stars
You can also filter your search using the –filter option. For example, if you want to filter Ubuntu Images which has a minimum of 10 stars, you can use this command.
sudo docker search --filter=stars=10 ubuntu
3. Filtering the Search on the basis of the Automated Parameter
To filter the search on the basis that the Image is automated or not, you can use this command.
sudo docker search --filter=is-automated=true ubuntu
4. Docker Search Manual
To know more about the Docker Search Command and what other options it provides, you can use the –help option.
sudo docker search --help
- –Filter: It filters the search output based on the conditions provided. We have already discussed how to use the Filter option.
- –no-trunc : The output of the search command is usually truncated in order to avoid long descriptions. You can use this option to specify if you want truncated output or not.
- –limit: You can use the flag to limit the number of search results.
- –format: It displays output in a readable format.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.