New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add -format to 'docker inspect' #2921
Conversation
Can you give us some example ? |
I imagine we'd want a proper docs page with some recipes, but, for example:
Now if you want to know the address it's bound to:
The structure of the networking section is, IMO, awkward, but workable (port maps to an array of objects). If you wanted a textual list of all portmappings, you could do this:
which yields
If you wanted the specific external port for that, you could do this:
yields
That one is particularly awkward, but, again, it's how the structure was defined. |
The previous commit update just adds a newline to the error message when your template can't be parsed. No functional change. |
Definitely huge +1 from me! I've been wanting someone to implement this one for a while. :) Getting at these values with nothing but bash as we are right now is cumbersome or requires extra tooling I don't even have installed (and can't justify for just this, especially given that the scripts I write usually run on the machines of other people who definitely won't install jq just for one or two little scripts). |
@dustin Can you add the examples to the docs page for inspect? |
@crosbymichael I'm happy to provide docs. Do you want them in |
Yes, a few examples under this command in cli.rst would be perfect. |
var err error | ||
if tmpl, err = template.New("").Parse(*tmplStr); err != nil { | ||
fmt.Fprintf(cli.err, "Template parsing error: %v\n", err) | ||
return &utils.StatusError{Status: 64} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Status's type changed to be a string
with a new field StatusCode
which is an int.
This makes it a lot easier to script with docker instances as one can ask for details about running instances more easily without having to have additional JSON processing tools installed. #734
rebased |
LGTM |
1 similar comment
LGTM |
This makes it a lot easier to script with docker instances as one can
ask for details about running instances more easily without having to
have additional JSON processing tools installed.
Note that I did minimal work in separating the current JSON output from the templated output.
#734
Closes #734