Issue
[banner@stapp03 ~]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 26828d185a8f 5 seconds ago 125MB
ubuntu latest 174c8c134b2a 3 weeks ago 77.8MB
there are 2 images - i want to type command in cli and grab latest image id (first row) and use it for other subsequent commands. Not use mouse click to select image id, how to do this?
Solution
If you want to print image id of the first image then you may use:
docker images | awk 'NR == 2 {print $3}'
Here:
NR == 2
: Selects 2nd row{print $3}
: Prints 3rd field i.e. Image Id
Answered By - anubhava Answer Checked By - Candace Johnson (WPSolving Volunteer)