I'd like to retrieve the port mapped to a container using docker inspect, I found something like that:
docker inspect --format=" {{ .NetworkSettings.Ports }} " containerid
Output:
map[1234/tcp:[map[HostIp:0.0.0.0 HostPort:49159]] 3306/tcp:<nil> 4444/tcp:<nil> 4567/tcp:<nil> 4568/tcp:<nil>]
But I'd like to have an output like this:
1234/tcp:49159
Is it possible ?
You can use index in your template:
See also my answer How to get ENV variable when doing Docker Inspect I guess you can adapt and get directly what you want
The
docker port
command may be more useful; it produces output like this: