Clearing Unnamed Docker Images

I’ve been playing around with Docker a lot lately and the number of images on my host keeps climbing. In doing so, I’ve managed to end up with a number of images which weren’t properly named/tagged and I really have no idea what they’re for at this point. Oh, sure, I could always just do a [shell]docker inspect image_id[/shell] on the image and see what it is, but I’m lazy. It’s easier just to get rid of them. 🙂

So if I use ‘docker images’ to see what I have available you can see I’ve got a number of images in the state I describe.

REPOSITORY                         TAG                 IMAGE ID            CREATED             SIZE
runlevl4/couch                     latest              c0d143528267        19 hours ago        573MB
runlevl4/openjdk                   latest              1a04169be1f0        20 hours ago        738MB
runlevl4/alpine-wso2               latest              382b74b4df93        11 days ago         757MB
<none>                             <none>              2fbbf4f7f2ae        11 days ago         757MB
runlevl4/alpine-wso2               v1                  581ac302a5e7        11 days ago         757MB
<none>                             <none>              3c2bd15fa447        11 days ago         757MB
centos7/nonroot                    v1                  03f554e67899        13 days ago         197MB
<none>                             <none>              e876350b9c92        13 days ago         197MB

Here’s a quick and easy way to get rid of them. First, we’ll do a dry run and just return the images we want to purge.

docker images | grep "<none>" | tr -s " " | cut -d " " -f 3

docker images – returns all the images on our host
grep “” – reduces the results to just those we’re after
tr -s ” ” – this is a fun one. the -s argument tells tr to replace all of the spaces with a single space
cut -d ” ” -f 3 – we use cut to reduce the results to just the image id. -d sets the delimiter as a single space and -f grabs the third field

Let’s see some examples as we build the command out.

docker images | grep "<none>"
<none>                             <none>              2fbbf4f7f2ae        11 days ago         757MB
<none>                             <none>              3c2bd15fa447        11 days ago         757MB
<none>                             <none>              e876350b9c92        13 days ago         197MB

Now we throw in the tr command.

docker images | grep "<none>" | tr -s " "
<none> <none> 2fbbf4f7f2ae 11 days ago 757MB
<none> <none> 3c2bd15fa447 11 days ago 757MB
<none> <none> e876350b9c92 13 days ago 197MB

And finally, we return just the image id.

docker images | grep "<none>" | tr -s " " | cut -d " " -f 3
2fbbf4f7f2ae
3c2bd15fa447
e876350b9c92

Now that we know our command is working, we can pass it as an argument to the [shell]docker rmi[/shell] command. ‘docker rmi’ is the CLI command to remove one or more Docker images.

docker rmi $(docker images | grep "<none>" | tr -s " " | cut -d " " -f 3)
Deleted: sha256:2fbbf4f7f2aef4d47d74a44ec32fe2cf8d3fd4650b7d216675908f3757651b21
Deleted: sha256:3c2bd15fa447d9e5ffd12e8d149147fb5dd66cb48c9f152748b42514abcaf5a1
Deleted: sha256:84243c17c3cf36e418afe44880b33490f537e91b81ef9ac78a3d345e6a7609b0
Deleted: sha256:e876350b9c92fce722c096ef989216f802b264276676219cc2f321ff279d5ba5

Now you can use [shell]docker images[/shell] again to confirm that they’re gone.

REPOSITORY                         TAG                 IMAGE ID            CREATED             SIZE
runlevl4/couch                     latest              c0d143528267        19 hours ago        573MB
runlevl4/openjdk                   latest              1a04169be1f0        20 hours ago        738MB
runlevl4/alpine-wso2               latest              382b74b4df93        11 days ago         757MB
runlevl4/alpine-wso2               v1                  581ac302a5e7        11 days ago         757MB
centos7/nonroot                    v1                  03f554e67899        13 days ago         197MB

Post to Twitter

WiFi, Wherefore Art Thou

So it’s been a couple of months since I replaced the keyboard on my Gazelle and I’m still digging it. There’s one other issue that I should mention that I hadn’t really worried about. I noticed the Bluetooth never worked. Since I already had a USB mouse it wasn’t a big deal until I started having other issues. Periodically I’d looked it up but never found any solid solutions. The Gazelle has a dual-purpose Intel 8260 WiFi/Bluetooth adapter and it seemed like there were issues with both the 7260 and 8260 under Linux. It also appeared that the issues were resolved in newer kernels but even upgrading to 4.6 didn’t resolve the issue. Nothing I did could even get the adapter to show up. Read More

Post to Twitter

Keyboard Trouble In Paradise

It’s been a while since I got my Gazelle laptop from System76. The matte display continues to wow me every time I turn it on. The speed with the i5 processor and my upgraded SSD makes this a screaming machine. I replaced the stock spinning drive with a 1TB Samsung 850 EVO drive which has been an absolute dream. I’m half tempted, though, to pick up an even faster m2 drive if prices come down enough. But I digress. Read More

Post to Twitter