update
This commit is contained in:
parent
7c19fe58a6
commit
d54328c001
@ -60,13 +60,16 @@ swarm.on('connection', (peer) => {
|
|||||||
console.log('[INFO] Handling \'listContainers\' command');
|
console.log('[INFO] Handling \'listContainers\' command');
|
||||||
const containers = await docker.listContainers({ all: true });
|
const containers = await docker.listContainers({ all: true });
|
||||||
|
|
||||||
// Fetch detailed network info for each container
|
|
||||||
const detailedContainers = await Promise.all(
|
const detailedContainers = await Promise.all(
|
||||||
containers.map(async (container) => {
|
containers.map(async (container) => {
|
||||||
const details = await docker.getContainer(container.Id).inspect();
|
const details = await docker.getContainer(container.Id).inspect();
|
||||||
|
console.log(details.NetworkSettings.Networks); // Log the network details
|
||||||
|
|
||||||
|
// Safely access the IP address
|
||||||
const ipAddress = details.NetworkSettings.Networks
|
const ipAddress = details.NetworkSettings.Networks
|
||||||
? Object.values(details.NetworkSettings.Networks)[0].IPAddress
|
? Object.values(details.NetworkSettings.Networks)[0]?.IPAddress || 'No IP Assigned'
|
||||||
: '-';
|
: 'No Networks';
|
||||||
|
|
||||||
return { ...container, ipAddress }; // Add IP address to container data
|
return { ...container, ipAddress }; // Add IP address to container data
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user