๐Ÿš€ Day-2: Docker Images and search images.

Ibrar AnsariIbrar Ansari
3 min read

๐ŸŽฌ Video Demonstration

Watch on Youtube

๐Ÿณ What is a Docker Image?

A Docker image is a lightweight, standalone, and executable package that includes everything needed to run a piece of software, including the code, runtime, libraries, and dependencies. Think of it as a snapshot or blueprint of an application! ๐Ÿ“ธ

  • Immutable: Docker images are read-only templates.

  • Layered: Built in layers for efficiency (e.g., base OS, libraries, app code).

  • Portable: Run consistently across different environments (local, cloud, etc.).

Docker images are stored in registries like Docker Hub, which is like a "GitHub for Docker images." ๏ฟฝ registry

๐Ÿ” Why Search for Docker Images?

Searching for Docker images allows you to:

  • Find pre-built images for popular software (e.g., nginx, python, mysql).

  • Save time by reusing community-maintained or official images.

  • Ensure you're using trusted and optimized images for your projects.

Docker Hub hosts millions of images, and searching efficiently helps you find the right one for your needs! ๐ŸŒ

๐Ÿš€ Steps to Work with Docker Images

  1. Install Docker: Ensure Docker is installed and running.

  2. Search for Images: Use the docker search command to find images on Docker Hub.

  3. Pull an Image: Download the desired image to your local machine using docker pull.

  4. Run a Container: Create a container from the image using docker run.

  5. List Images: View all downloaded images with docker images.

๐Ÿ“ Example Commands

Here are some practical commands to get you started:

1. Search for a Docker Image

# Search for images with the specified name in Docker Hub
docker search image-name

# Search for images and limit the number of results
docker search --limit 5 image-name

# Search for images with automated builds
docker search --filter is-automated=true image-name

# Search for official images only
docker search --filter is-official=true image-name

# Search for images with a minimum number of stars
docker search --filter stars=10 image-name

# Search for images and format the output
docker search --format "{{.Name}}: {{.Description}}" image-name

# Search for images and include truncated descriptions
docker search --no-trunc image-name

# Search quietly, outputting only image names
docker search -q image-name

This lists available nginx images on Docker Hub, showing details like name, description, and stars. โญ

2. Pull a Docker Image

To download the official nginx image:

docker pull nginx

3. List Local Images

To see all images on your machine:

docker images

4. Run a Container

To start a container from the nginx image:

docker run -d -p 8080:80 nginx

This runs nginx in the background (-d) and maps port 8080 on your machine to port 80 in the container.

5. Remove an Image

To delete an image (replace <image_id> with the actual ID from docker images):

docker rmi <image_id>

Note

In this series of docker zero to zero I am going to use these images as well.

ibraransaridocker/network-debug-tools   latest    
ibraransaridocker/whoami                latest    
ibraransaridocker/coming-soon           latest    
ibraransaridocker/under-maintenance     latest    
ibraransaridocker/nginx-demo            latest    
ibraransaridocker/dotfiles              latest

Happy Dockering! ๐Ÿณโœจ

0
Subscribe to my newsletter

Read articles from Ibrar Ansari directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ibrar Ansari
Ibrar Ansari

Hello! I'm a DevOps Engineer dedicated to continuous learning and contributing to the tech community. If you find value in what I share, feel free to spread the word to others who might benefit as well. Your support is greatly appreciated!