docs: Fix template error in cli example (#3727)#3728
Conversation
|
Hmm... right, so I think the problem in your case was that you were using the example on a container that did not map any ports (i.e., no For example; docker run -d --name foo nginx:alpine
6757f08870ace82b937eecadda2e8d689cf1ea4eb263af65afa8add4576ad953
docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' foo
Template parsing error: template: :1:59: executing "" at <index $conf 0>: error calling index: index of untyped nilDoing the same but with a container that does publish ports will show the expected output; docker run -d --name foo2 -p 8080:80 -p 8081:443 nginx:alpine
5788ced50b6fb9ea726d6ffd36403fcb84a981e4ebc7950f9288bd3562fd7200
docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' foo2
443/tcp -> 8081 80/tcp -> 8080I'm a bit confused about the addition of |
You are right, it's not working with It should be like this: $ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{with $conf}}{{(index . 0).HostPort}}{{else}}none{{end}} {{end}}' foo
3306/tcp -> none 33060/tcp -> noneIn this case it will not throw an error in your first example and will give the same output as in your second example. I'm going to fix my copy-pasting error in pr soon. Sorry about that. And thanks for your work! |
|
Sorry for the delay; thank you! The change itself looks good, but some issues with the commit(s).
We require all commit messages to have a There is no need to open a new pull request, but to fix this (and make CI pass), Unfortunately, it's not possible to do so through GitHub's web UI, so this needs You can find some instructions in the output of the DCO check (which can be found Steps to do so "roughly" come down to:
Sorry for the hassle (I wish GitHub would make this a bit easier to do), and let me know if you need help or more detailed instructions! |
d92b98a to
43c6db2
Compare
|
I'm sorry for the delay.. I squashed and signed off my commit. Thanks! |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Signed-off-by: Max Morozov <max@morozov.page> Signed-off-by: Max Morozov <gtmax.yo@gmail.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Fixes issue #3727