From d54328c0017b650e777af40b143d4229b725e823 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Fri, 29 Nov 2024 18:27:37 -0500 Subject: [PATCH] update --- server/server.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/server.js b/server/server.js index 92b4168..cdeaf19 100644 --- a/server/server.js +++ b/server/server.js @@ -60,13 +60,16 @@ swarm.on('connection', (peer) => { console.log('[INFO] Handling \'listContainers\' command'); const containers = await docker.listContainers({ all: true }); - // Fetch detailed network info for each container const detailedContainers = await Promise.all( containers.map(async (container) => { 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 - ? 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 }) );