Introduction
Another article with the content focusing on the usage of docker tool. But the focus is about how to search a docker image in a local docker repository. Actually, in the previous article, there is a content for showing how to run a local docker repository. So, after it is running, it is possible to search for a docker image in that local docker repository.
In order to check what is a local docker repository in Microsoft Windows for detail specifically the installation process, look at the article in this link. It is an article with the title of ‘How to Run Local Docker Repository in Microsoft Windows’ for a reference.
Search Docker Image in a Local Docker Repository
Basically, an attempt to use the syntax command which is a success when searching docker image in a public local docker repository ends in a failure. There is an article with the title of ‘How to Search a Docker Image in a Docker Repository’ in this link. Before going on to the command on searching the docker image, there is a syntax pattern :
C:\Windows\system32>docker search --help Usage: docker search [OPTIONS] TERM Search the Docker Hub for images Options: -f, --filter filter Filter output based on conditions provided --format string Pretty-print search using a Go template --limit int Max number of search results (default 25) --no-trunc Don't truncate output C:\Windows\system32>
The following are several attempts for searching docker image including the syntax command searching docker image in public docker repository : . The following is an output for that command execution using the above syntax pattern :
-
The first attempt is an attempt for searching docker image in the local docker repository using the syntax command for searching docker image in a public docker repository with the above syntax pattern :
C:\Windows\system32>docker search http://localhost:5000 centos "docker search" requires exactly 1 argument. See 'docker search --help'. Usage: docker search [OPTIONS] TERM Search the Docker Hub for images C:\Windows\system32>
-
The second attempt is an attempt to revise the previous attempt by reducing the argument. The following is the revision of the command execution :
C:\Windows\system32>docker search http://localhost:5000/centos Error response from daemon: Invalid repository name (ex: "registry.domain.tld/myrepos") C:\Windows\system32>
-
Since the previous command execution is also end in a failure, the following is another revision from the above command :
C:\Windows\system32>docker search localhost:5000/centos Error response from daemon: Unexpected status code 404 C:\Windows\system32>
-
Unfortunately, the above command is also end in a failure. So, another attempt by revising the previous command above exist as follow :
C:\Windows\system32>docker search hub.docker.local:5000/centos Error response from daemon: Unexpected status code 404 C:\Windows\system32>
In this context, using the ‘hub.docker.local’ name as an example is the suitable value. This is because the name for the local docker repository can exist as a definition in ‘C:\Windows\system32\drivers\etc\hosts’ file.
-
All the above command pattern for searching docker image is not working in the local docker repository. Even though it is working in the public docker repository. So, the next attempt is using another syntax command as follows :
C:\Windows\system32>curl -X GET http://localhost:5000/v2/_catalog {"repositories":["centos","local-alpine"]} C:\Windows\system32>
Gladly, the command above is a success. So, the address for displaying the list of container available is in ‘http://localhost:5000/v2/_catalog. It is also working and displaying the result as in the execution of the URL address in the web browser.
-
This is another attempt to search the docker image in the local docker repository with a different syntax command :
C:\Windows\system32>docker exec -it hub.local ls -a /var/lib/registry/docker/registry/v2/repositories/ . centos .. local-alpine C:\Windows\system32>
Actually, all of the syntax command which is displaying the list is not completely specific. In other words, it does not display any means to specify the keyword for search parameter.
So, it is not searching a specific docker image with a keyword name but a little bit more like listing the docker image available in the local docker repository. The following is another attempt which is more likely close enough as searching a specific docker image but ends in a failure :
C:\Windows\system32>curl -X GET http://localhost:5000/v1/search 404 page not found C:\Windows\system32>curl -X GET http://localhost:5000/v1/search?q=centos 404 page not found C:\Windows\system32>