search_docker_images
Find Docker container images on DockerHub by name or keywords to discover official and community images for specific services, applications, or technologies.
Instructions
Search for Docker images on DockerHub by name or keywords.
USE THIS WHEN: You need to find Docker container images for a specific service, application, or technology.
BEST FOR: Discovering official and community Docker images.
Returns multiple matching images with names, descriptions, star counts, pull counts, and whether they're official.
After finding an image, use:
- docker_image_metadata() for detailed information
- fetch_docker_image_docs() for README and usage instructions
- fetch_dockerfile() to see how the image is built
Args:
query: Search query (e.g., "nginx", "postgres", "machine learning", "python")
limit: Maximum number of results (default 5)
Returns:
JSON with list of matching images including name, description, stars, pulls, official status
Example: search_docker_images("postgres") → Finds official postgres image and alternatives
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| limit | No |
Implementation Reference
- src/RTFD/providers/dockerhub.py:322-347 (handler)The main handler function for the 'search_docker_images' tool. It wraps the private _search_images method and serializes the response using serialize_response_with_meta.async def search_docker_images(query: str, limit: int = 5) -> CallToolResult: """ Search for Docker images on DockerHub by name or keywords. USE THIS WHEN: You need to find Docker container images for a specific service, application, or technology. BEST FOR: Discovering official and community Docker images. Returns multiple matching images with names, descriptions, star counts, pull counts, and whether they're official. After finding an image, use: - docker_image_metadata() for detailed information - fetch_docker_image_docs() for README and usage instructions - fetch_dockerfile() to see how the image is built Args: query: Search query (e.g., "nginx", "postgres", "machine learning", "python") limit: Maximum number of results (default 5) Returns: JSON with list of matching images including name, description, stars, pulls, official status Example: search_docker_images("postgres") → Finds official postgres image and alternatives """ result = await self._search_images(query, limit) return serialize_response_with_meta(result)
- Private helper method that implements the core logic: queries DockerHub search API, transforms results into structured format with owner, description, stats, and handles errors.async def _search_images(self, query: str, limit: int = 5) -> dict[str, Any]: """Search for Docker images on DockerHub. Args: query: Search query (image name) limit: Maximum number of results to return Returns: Dict with search results """ try: url = f"{self.DOCKERHUB_API_URL}/search/repositories/" params = {"query": query, "page_size": limit} async with await self._http_client() as client: resp = await client.get(url, params=params) resp.raise_for_status() payload = resp.json() # Transform results results = [] for item in payload.get("results", []): repo_name = item.get("repo_name", "") repo_owner = item.get("repo_owner", "") # For official images, repo_owner is empty, show as library/name display_name = f"{repo_owner}/{repo_name}" if repo_owner else f"library/{repo_name}" results.append( { "name": repo_name, "owner": repo_owner or "library", "description": item.get("short_description", ""), "star_count": item.get("star_count", 0), "pull_count": item.get("pull_count", 0), "is_official": item.get("is_official", False), "url": f"https://hub.docker.com/r/{display_name}", } ) return { "query": query, "count": len(results), "results": results, } except httpx.HTTPStatusError as exc: return { "query": query, "error": f"DockerHub returned {exc.response.status_code}", "results": [], } except httpx.HTTPError as exc: return { "query": query, "error": f"DockerHub request failed: {exc}", "results": [], } except Exception as exc: return { "query": query, "error": f"Failed to search images: {exc!s}", "results": [], }
- src/RTFD/providers/dockerhub.py:436-442 (registration)Registration of the 'search_docker_images' tool in the get_tools() method's dictionary, which returns the MCP tool functions.tools = { "search_docker_images": search_docker_images, "docker_image_metadata": docker_image_metadata, } if is_fetch_enabled(): tools["fetch_docker_image_docs"] = fetch_docker_image_docs tools["fetch_dockerfile"] = fetch_dockerfile
- src/RTFD/providers/dockerhub.py:21-22 (registration)Declaration of tool_names list in get_metadata(), including 'search_docker_images' for provider metadata.tool_names = ["search_docker_images", "docker_image_metadata"] if is_fetch_enabled():