Access IP address of Couchbase container on Docker Swarm cluster

0 votes

Trying to run a Couchbase cluster on Docker Swarm cluster. 

Once the cluster is started, I want to obtain the IP address of each Couchbase instance dynamically. 

docker inspect gives this:

"NetworkSettings": {
        "Bridge": "",
        "SandboxID": "325807d55b552be3fe5b44b4d975c2486b3a56b320aa56fa0367e42348b82d64",
        "HairpinMode": false,
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "Ports": {
            "11207/tcp": null,
            "11210/tcp": [
                    "HostIp": "",
                    "HostPort": "11210"

Trying to access the IP address gives the error:

docker inspect --format '{{ .NetworkSettings.Ports.8091/tcp[0].HostIp }}' 922755302fef
Template parsing error: template: :1: unexpected ".8091" in operand; missing space?
Aug 24, 2018 in Docker by lina
• 8,100 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

The property .NetworkSettings.Ports is a map, not a struct. You can use the index template function to access the map values:

$ docker inspect --format '{{ index .NetworkSettings.Ports "8091/tcp" 0 "HostIp" }}'
answered Aug 24, 2018 by Nilesh
• 6,900 points

Related Questions In Docker

+4 votes
4 answers

How To Access a Service on Host From a Docker Container?

Adding to kalgi's answer, You can also ...READ MORE

answered Oct 16, 2018 in Docker by lina
• 8,100 points

edited Oct 16, 2018 by lina 2,550 views
0 votes
1 answer
0 votes
1 answer

Docker ports are working on the localhost but not with public ip

Probably, the reason is that you've included ...READ MORE

answered Jun 12, 2018 in Docker by Damon Salvatore
• 5,450 points

edited Oct 15, 2018 by Kalgi 207 views
0 votes
1 answer
+5 votes
7 answers

Docker swarm vs kubernetes

Swarm is easy handling while kn8 is ...READ MORE

answered Aug 27, 2018 in Docker by Mahesh Ajmeria
0 votes
1 answer

Init could not choose ip address error while doing docker swarm init

First look for the public IP of ...READ MORE

answered Aug 23, 2018 in Docker by Nilesh
• 6,900 points
0 votes
2 answers

Can't access apache karaf docker container

To access karaf shell directly you can ...READ MORE

answered Aug 6, 2018 in Docker by Nilesh
• 6,900 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.