DEV Community

Cover image for 🌈 Show me your DockerHub public images in your terminal
adriens for opt-nc

Posted on β€’ Edited on

5 2

🌈 Show me your DockerHub public images in your terminal

❔ Intro

Docker Registry HTTP API V2 make is possible to query the registry in a comfortable way.

To showcase our public images, I wonder if I could :

  • Learn more about the API
  • Play with jq options
  • Showcase some content in a fun yet interesting way, from the terminal itself
  • Generate other kinds of creative ideas around this topic

πŸ’‘ The idea

To put in evidence the popularity of our images to the team that builds them,

I wanted to display a ranking they could play with on their workstations... right into their terminal

🧰 Tooling

Therefore I used the tool the team already uses on a daily basis to test & document our APIs :

  • httpie : "As easy as /aitch-tee-tee-pie/ pie Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. "
  • jq : "jq is like sed for JSON data"

... and for the fun and geek culture :

  • lolcat : "Rainbows and unicorns!"
http https://hub.docker.com/v2/repositories/optnc | \
     jq -r '"Image\tPulls", "-----------------------\t---", ( .results | sort_by(.pull_count) | reverse | .[] | "\(.name)\t\(.pull_count)")' | \
 column -t -s $'\t' | \
 lolcat -a -d 20
Enter fullscreen mode Exit fullscreen mode

🍿 Demo

Here is the final demo :

Find the movie source code just below (so you can replay or customize it) :

# πŸ€“ Let's see at optnc's public images on DockerHub πŸŽ‡

http https://hub.docker.com/v2/repositories/optnc | jq -r '"Image\tStars\tPulls", "-----------------------\t-------\t------", ( .results | sort_by(.pull_count) | reverse | .[] | "\(.name)\t\(.star_count)\t\(.pull_count)")' | column -t -s $'\t'

# 🎬 Now watching the spicy way 🌈

clear && http https://hub.docker.com/v2/repositories/optnc | \
     jq -r '"Image\tPulls", "-----------------------\t---", ( .results | sort_by(.pull_count) | reverse | .[] | "\(.name)\t\(.pull_count)")' | \
 column -t -s $'\t' | \
 lolcat -a -d 20

# πŸ™πŸ» Hopefully you enjoyed this short demo πŸ™‹
Enter fullscreen mode Exit fullscreen mode

πŸ”– Resources

πŸ“œ Drafts

Below drafts that helped create the final version πŸ‘‡

http https://hub.docker.com/v2/repositories/optnc | jq -r '.results|.[] | "\(.name)\t\(.star_count)"'  | column -t -s $'\t'
Enter fullscreen mode Exit fullscreen mode

Then the aligned version :

http https://hub.docker.com/v2/repositories/optnc | jq -r '"Image\tStars", "-----------------------\t-------", ( .results|.[] | "\(.name)\t\(.star_count)" )' | column -t -s $'\t'
Enter fullscreen mode Exit fullscreen mode

Sorting desc by stars :

http https://hub.docker.com/v2/repositories/optnc | jq -r '( .results | sort_by(.star_count) | reverse | .[] | "\(.name)\t\(.star_count)")' | column -t -s $'\t'
Enter fullscreen mode Exit fullscreen mode

Then with lolcat piping :

http https://hub.docker.com/v2/repositories/optnc | jq -r '"Image\tStars\tPulls", "-----------------------\t-------\t------", ( .results | sort_by(.pull_count) | reverse | .[] | "\(.name)\t\(.star_count)\t\(.pull_count)")' | column -t -s $'\t' | lolcat
Enter fullscreen mode Exit fullscreen mode

API Trace View

How I Cut 22.3 Seconds Off an API Call with Sentry πŸ‘€

Struggling with slow API calls? Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more β†’

Top comments (2)

Collapse
 
adriens profile image
adriens β€’

Post used to help improve shields.io :

πŸ› Docker stars broken (invalid) ⭐ #8314

Are you experiencing an issue with...

shields.io

🐞 Description

Docker stars shield is broken :

image

While docker repo is ok :

hub.docker.com/r/optnc/api-transit...

πŸ”— Link to the badge

Can be reproduced on any docker image with /docker/stars/

πŸ’‘ Possible Solution

Maybe point to this API https://hub.docker.com/v2/repositories/optnc which makes it possible to get the stars with star_count attribute

Collapse
 
adriens profile image
adriens β€’

Sentry image

See why 4M developers consider Sentry, β€œnot bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more