Docker Command One Liners

Docker Command One Liners

Docker Logo



Docker Command One Liners

I love the code snippets, it’s how I learn any syntax by rolling up the sleeves, hacking and breaking while taking notes along the way. It’s probably not the most efficient but the muscle memory is how I learn. Here is a list of one liners from my notes in no particular order (even though I tried to in a couple of places :).

This post is for people fairly new to Docker or looking to build out their command notes list. The Docker API is as nice of a CLI as there has ever been. It is very intuitive and exemplifies the practicality of Golang. The list also drives home the ease of use that is at the heart of why Docker is adopting so rapidly. I see it almost daily now, the lightbulb comes on when they use Docker for the first time and spin up what usually takes a long multi-Gig download, patching, compiling sw etc and is condensed into a 50-80MB download and a fraction of a second to start.

Whether a network professional, sys admin, devops, sw eng, product manager, etc once they use Docker, they often come to the same conclusion, how apps are delivered will look radically different over the next couple of years. It is truly infrastructure as code that lowers the ability to install software and incrementally pattern systems with as much granularity as you desire that can be replicated that consistently time after time. For those providing software to customers or to production, there has never been a simpler way to deliver your intent to the user or service with the exact experience you want them to have without the exposed complexity that was becoming far too pervasive in today’s infra.


If you are new to Docker

If you are new to Docker, check out the Docs and pick the OS you’re running:

Install Docker Instructions

What excites many (including myself) is that traditional technological barriers and “how we have always done things” are being overcome by open source composable building blocks. While everyone has some degree of opinion on “best practice” new patterns are emerging daily that challenge what was either not technically feasible or had a complexity factor that made it impractical.


Dockerfile and Containers is Code as Infrastructure

Before the list, there may be one command here folks might not be familiar with. To clear up the magic, xargs is a handy command that in the examples below takes the results as a string from a docker command that breaks on whitespace and then uses the stored string as a parameter.

I also drop them into my ~/.bash_profile (Mac) or ~/.bashrc for aliasing for that extra fraction of efficiency 🙂

Apologies for any duplicates, I will proof it better later in the week. There will be typos and errors but thats ok, if new to Docker it will all be fun and learning with a syntax debug or two 🙂


Docker Machine CLI Command One Liners

If you haven’t tried out Docker Machine yet you should give it a whirl, its pretty damn cool.

Here are my aliases for it from my ~/.bash_profile

You can download all of the Docker CLI one liners above from github here.


I will keep adding as new features come in and what not. I have no doubt there are tons of duplicates but I have just run out of time so will clean them up another day. Will also get to more advanced topics soon but for my friends new to Docker, basics first. Beauty is, u can master the APIs in no time because they aren’t insane and super easy to consume.

Next time you want to share an app with someone, try sending a file that will download <100MB with the ability to configure the app exactly how you want it rather then a file that will pull down full blown operating systems without native means to deploy the App how you intended not guessing the hundreds/thousands of potential variable states in the target host environment. Rather then trying to keep the state of your systems from gradually eating themselves over time, it is worth giving some thought to a less mutable infrastructure that you simply recreate rather then repair. In the meantime, keep the coffee coming and the containers running!

About the Author

Brent SalisburyI have over 15 years of experience wearing various hats from, network engineer, architect, devops and software engineer. I currently have the pleasure of working at the company that develops my favorite software I have ever used, Docker. My comments here are my personal thoughts and opinions. More at Brent's BioView all posts by Brent Salisbury →