DEV Community

tetractius
tetractius

Posted on

TetraQuicky04: Recover docker parameter used to run a container

How many time you managed to run a container with exactly the parameter and the configuration you needed but you for some reason your Ctrl+r is not finding anymore in your history the exact flags you used...
Damn it that was exactly what you need. I needed that so that I throw it at my Kubernetes/rancher/swarm/whatever orchestrator to finish this stuff and go home...

Yes, you can start to docker inspect the hell out of a container but you don't really want that. It's late and you just want to go home. Or you don't care because you are not one of those DevOps wizards that always fix everything and you only care in getting your container up and running.

Well, this guy has exactly the solution for you!!

And I have been using it like a crazy guy because it just works:

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
    assaflavie/runlike YOUR-CONTAINER

then, as the author suggests, you can alias it:

alias runlike="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie/runlike"

so that you can easily stuff like that:

$ runlike -p redis

docker run \
    --name=redis \
    -e "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
    -e "REDIS_VERSION=2.8.9" \
    -e "REDIS_DOWNLOAD_URL=http://download.redis.io/releases/redis-2.8.9.tar.gz" \
    -e "REDIS_DOWNLOAD_SHA1=003ccdc175816e0a751919cf508f1318e54aac1e" \
    -p 0.0.0.0:6379:6379/tcp \
    --detach=true \
    myrepo/redis:7860c450dbee9878d5215595b390b9be8fa94c89 \
    redis-server --slaveof 172.31.17.84 6379

Boom!!

Job done... now I can go home (or in time of quarantine, I can just go to the kitchen to cook something).

Top comments (0)