Skip to content

Instantly share code, notes, and snippets.

View manuel-rubio's full-sized avatar
👋
Say Hi! and let me know if you want to contribute!

Manuel Rubio manuel-rubio

👋
Say Hi! and let me know if you want to contribute!
View GitHub Profile
@manuel-rubio
manuel-rubio / get-run-cmd
Last active August 2, 2021 14:10 — forked from djmaze/get-run-cmd
Get run command from running Docker container
#!/bin/bash
set -eo pipefail
container=$1
image=$(docker inspect --format '{{.Config.Image}}' $container)
cmd=$(docker inspect --format '{{.Config.Cmd}}' $container)
if [[ $cmd == '<nil>' ]]; then cmd=''; fi
binds=$(docker inspect --format '{{.HostConfig.Binds}}' $container | sed "s/\[//; s/\]//")
if [[ $binds == '<nil>' ]]; then binds=''; fi
envs=$(docker inspect --format '{{.Config.Env}}' $container | sed "s/\[//; s/\]//")