Skip to content
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

docker inspect --format .NetworkSettings.Ports doesn't work in Windows #27592

Closed
emzeidan opened this issue Oct 20, 2016 · 3 comments
Closed

Comments

@emzeidan
Copy link

Hi team,

I am a Support Engineer from Atlassian and I'm working with a customer on an issue.

The following docker inspect command consistently does not seem to work on Windows:
docker.exe inspect --format='{{(index (index .NetworkSettings.Ports "3000/tcp") 0).HostPort}}' $INSTANCE_ID.

The command returns the following error:

Template parsing error: template: :1: unexpected "/" in operand

In docker-archive/toolbox#433, there was a suggestion to switch the quotes from single to double, but that does not work, returning:

Template parsing error: template: :1: malformed character constant: '3000/tcp'

The issue was tested on CentOS and it does work there.

I apologize if this is a duplicate issue, I was unable to find an existing one.

Thanks in advance!

@emzeidan
Copy link
Author

emzeidan commented Oct 20, 2016

Hi team, a quick update from our side. From our testing, it looks like escaping the internal quotes works:
docker.exe inspect --format="{{(index (index .NetworkSettings.Ports \"3000/tcp\") 0).HostPort}}" $INSTANCE_ID

Thanks!

@thaJeztah
Copy link
Member

Looks like you found the error, so I'll close

@573
Copy link

573 commented Jan 8, 2019

What should work as well is:

docker.exe inspect --format '{{(index (index .NetworkSettings.Ports "3000/tcp") 0).HostPort}}' $INSTANCE_ID

v1v added a commit to v1v/docker that referenced this issue Oct 31, 2020
…t: 'org.label-schema.version'

See example of escaping double quotes moby/moby#27592
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants