McLean IT Consulting

WORRY FREE IT SUPPORT

Call Us: 250-412-5050
  • About
  • Services
    • IT Infrastructure Design
    • Remote & Onsite IT Support
    • Disaster Recovery
    • IT System Monitoring
    • IT Audit
    • Documentation
    • Medical IT Solutions
    • Wireless Networks
    • Cloud Computing
    • Virtualization
  • Partners
    • Lenovo
    • Ubiquiti Networks
    • Dragon Medical Practice Edition (Nuance)
    • Synology
    • Drobo
    • Adobe
    • Bitdefender
    • NAKIVO
  • Contact
  • Blog
  • Remote Support

Documenting Docker Run Commands

November 20, 2016 By Andrew McLean Leave a Comment

Docker logo
I know it’s been a long time since I wrote anything on here. Frankly, I’ve been busy with work, and other personal projects. But it is worth noting that most of those projects were professionally oriented. Specifically, I’ve been teaching myself aspects of vSphere, Docker, and a host of other technologies. Late this summer I invested in a couple of nice Dell R710 servers which I’ve turned into a homelab wonderland.

With my new vSphere system, I now have a dedicated Docker box. I’ve been working with it for a couple of months now, running microservices like my Unifi controller, a CrashPlan container, even a couple of music managers like Headphones and Beets. I have an affinity for the team at linuxserver.io for their oft-updated and very well documented base images.

The problem is, I was playing around with it so much and making so many changes that I neglected to document the “docker run” commands correctly. I didn’t really document them at all. Every once in a while I’d like to perform a “docker pull” to retrieve the latest docker image and update my running containers, so the docker run commands along with the associated mapped ports and volumes would be extremely useful and time-saving.

I was looking for a way to reconstruct the original commands I used to build these containers. A number of possibilities presented themselves, but fortunately because I have a dedicated box (that is, not polluted with a lot of commands for unrelated services), I was able to recover exactly what the run commands were.

I simply made a copy of my bash history. It contained all of the exact commands are used to create the doctor containers from the very beginning. No guesswork, no time-consuming reconstruction of the commands. Just an exhaustive list of the last few hundred commands I’d performed with that user on that box.

I saw a bunch of online questions asking for basically the same thing, and instead of inferring the commands with “docker inspect” and parsing the results using Python, I thought I would offer an alternative.

Hopefully this proves useful to someone other than myself.

My docker host is running Ubuntu 16.04. I’m not sure if this is universal across all linux distros but it worked here:

history -w ~/history.txt

From there I just opened the text file and ran a search for all mentions of “docker run” and copied the last command string for each container.

Filed Under: Tips

Leave a Reply Cancel reply

You must be logged in to post a comment.

Contact Us

McLean IT Consulting Inc.
Serving Greater Victoria

P: 250-412-5050
E: info@mcleanit.ca
C: 250-514-2639

Featured Article

Business IT 101: Why Have a Server?

The question of whether or not to have a server comes up often in small business. I see lots of local businesses struggling to get by without a server … Continue Reading

Blog Categories

Our Mission

We seek to enrich and improve small and medium businesses by delivering best-in-class technology solutions, and offering a premier customer service experience. Contact Us Now!

Quick Menu

  • About
  • Testimonials
  • Contact
  • Blog
  • Sitemap

Let’s Get Social

  • Email
  • Facebook
  • LinkedIn
  • Twitter
  • YouTube

Copyright © 2025