Docker provides a powerful set of filtering options when working with commands like docker ps, docker images, and other list-related commands. Here's a checklist of Docker filter commands with examples:
1. Filter by Name:
Filter containers or images by name.
docker ps --filter "name=mycontainer"
docker images --filter "reference=myimage:1.0"
2. Filter by ID:
Filter containers or images by ID.
docker ps --filter "id=1234567890ab"
docker images --filter "id=sha256:abcdef123456"
3. Filter by Label:
Filter containers or images by label.
docker ps --filter "label=mylabel=myvalue"
docker images --filter "label=mylabel=myvalue"
4. Filter by Status:
Filter containers by status (running, exited, etc.).
docker ps --filter "status=running"
docker ps --filter "status=exited"
5. Filter by Exited Containers:
Filter containers by the exit code.
docker ps -a --filter "exited=1"
6. Filter by Publish Ports:
Filter containers by published ports.
docker ps --filter "publish=80"
7. Filter by Network:
Filter containers by network.
docker ps --filter "network=my_network"
8. Filter by Volume:
Filter containers by volume.
docker ps --filter "volume=my_volume"
9. Filter by Health:
Filter containers by health status.
docker ps --filter "health=healthy"
10. Filter by Isolation:
- Filter containers by isolation technology (e.g., hyperv).
docker ps --filter "isolation=hyperv"
11. Filter by Type:
- Filter images by type (e.g., dangling).
docker images --filter "dangling=true"
12. Filter by Before/After:
- Filter containers or images created before or after a specific timestamp.
docker ps --filter "before=timestamp"
docker images --filter "since=timestamp"
13. Filter by Volume Driver:
- Filter containers by volume driver.
docker ps --filter "volume-driver=my_volume_driver"
14. Filter by Build:
- Filter images by build.
docker images --filter "label=com.docker.compose.project=myproject"
15. Combine Multiple Filters:
- Combine multiple filters with a comma.
docker ps --filter "name=mycontainer" --filter "status=running"
These filter options provide flexibility when listing or inspecting Docker containers, images, and other resources. Adjust the filters based on your specific use case and requirements.
Docker search command
The docker search command allows you to search for Docker images on Docker Hub or any other specified registry. Here's a checklist of docker search command options with examples:
1. Search for an Image:
Search for an image on Docker Hub.
docker search nginx
2. Limit Results by Number:
Limit the number of results displayed.
docker search --limit 5 nginx
3. Filter by Stars:
Filter images based on the number of stars.
docker search --filter "stars=3" nginx
4. Filter by Official Images:
Filter to show only official images.
docker search --filter "is-official=true" nginx
5. Filter by Automated Builds:
Filter to show only automated build images.
docker search --filter "is-automated=true" nginx
6. Filter by Trusted Images:
Filter to show only trusted images.
docker search --filter "is-trusted=true" nginx
7. Filter by Most Recently Updated:
Sort the results by most recently updated.
docker search --filter "stars=3" --filter "is-official=true" --filter "is-automated=true" --filter "is-trusted=true" --filter "stars=3" --filter "is-official=true" --filter "is-automated=true" --filter "is-trusted=true" --filter "is-trusted=true" --filter "is-trusted=true" nginx
8. Display Only Official Images:
Display only official images.
docker search --filter "is-official=true" nginx
9. Display Only Automated Builds:
Display only automated build images.
docker search --filter "is-automated=true" nginx
10. Display Only Trusted Images:
- Display only trusted images.
docker search --filter "is-trusted=true" nginx
11. Filter by Architecture:
- Filter images by architecture.
docker search --filter "architecture=amd64" nginx
12. Filter by OS:
- Filter images by operating system.
docker search --filter "os=linux" nginx
13. Filter by Type:
- Filter images by type (e.g., plugin).
docker search --filter "type=plugin" nginx
14. Filter by Description:
- Filter images by description.
docker search --filter "description=alpine" nginx
15. Filter by Maintainer:
- Filter images by maintainer.
docker search --filter "maintainer=nginx" nginx
These options allow you to customize your search results based on various criteria, helping you find the most relevant images for your requirements. Adjust the filters based on your specific needs.
Top comments (0)