Skip to content

Instantly share code, notes, and snippets.

View hervenicol's full-sized avatar
👀
just looking around

Hervé Nicol hervenicol

👀
just looking around
View GitHub Profile
@hervenicol
hervenicol / run.tpl
Last active May 12, 2023 14:20 — forked from efrecon/run.tpl
`docker inspect` template to regenerate the `docker run` command that created a container
docker run \
--name={{.Name}} \
{{range $e := .Config.Env}}--env={{printf "%q" $e}} \
{{end}}{{range $p, $conf := .NetworkSettings.Ports}}{{with $conf}}-p {{(index $conf 0).HostIp}}:{{(index $conf 0).HostPort}}:{{$p}} \
{{end}}{{end}}{{range $n, $conf := .NetworkSettings.Networks}}{{with $conf}}--network {{printf "%q" $n}} \
{{range $conf.Aliases}}--network-alias {{printf "%q" .}} {{end}} \
{{end}}{{end}}{{range $v := .HostConfig.VolumesFrom}}--volumes-from={{printf "%q" .}} \
{{end}}{{range $v := .HostConfig.Binds}}--volume={{printf "%q" .}} \
{{end}}{{range $l, $v := .Config.Labels}}--label {{printf "%q" $l}}={{printf "%q" $v}} \
{{end}}{{range $v := .HostConfig.CapAdd}}--cap-add {{printf "%q" .}} \