Mike Putnam

profile-pic All posts ... rss-atom-feed
Connect via: Github Instagram LinkedIn Twitter Youtube
Get involved: Appleton Makerspace Wisconsin Linux Users

How can you organize your docker containers?

The moment you cross over the mental threshold from using docker for local development/experimentation to using docker as a host for important things, you'll begin to have questions. One of the early questions I had was, "How can I organize all these containers when all $ docker ps -a gives me is "NAMES"? The answer to that question is Labels!

Image source: http://imagegenerator.fuzzimo.com/embossedlabels/

You can assign labels to images within Dockerfiles or to containers with the $ docker run and $ docker daemon commands.

You can query for images with $ docker images --filter "label=color=blue", containers with $ docker ps --filter "label=color=blue" or via $ docker inspect

Docker treats the labels as simple strings, but if you want to get fancy you can store string-escaped JSON data if you want to write your own label parser.