Hi,
Is there any way to read the ip address of swarm tasks?
I make a docker client poniting to the leader of the swarm via:
DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost("unix:///var/run/docker.sock").build();
DockerClient client = DockerClientBuilder.getInstance(config).build();
I read the tasks of a service by:
List<Task> tasks = client.listTasksCmd().withServiceFilter(serviceName).exec();
Then I tried the following two ways to find the ip address of a task:
fetching continer by id:
TaskStatus status = task.getStatus();
TaskStatusContainerStatus containerStatus = status.getContainerStatus();
String containerID = containerStatus.getContainerID();
List<String> idfilter = new ArrayList<>();
idfilter.add(id);
List<Container> list = client.listContainersCmd().withShowAll(true).withIdFilter(idfilter).exec();
fetching container from overlay network:
List<Network> netList = client().listNetworksCmd().withNameFilter(new String[]{netName}).exec();
Network network = netList.get(0);
Map<String, Network.ContainerNetworkConfig> containers = network.getContainers();
But both return an empty list - or they do not return the containers that are placed on other swarm nodes.
Is this feature supported in the API?
Thanks!
Reactions are currently unavailable
Hi,
Is there any way to read the ip address of swarm tasks?
I make a docker client poniting to the leader of the swarm via:
I read the tasks of a service by:
Then I tried the following two ways to find the ip address of a task:
But both return an empty list - or they do not return the containers that are placed on other swarm nodes.
Is this feature supported in the API?
Thanks!