mirror of
https://github.com/fosrl/newt.git
synced 2026-03-08 03:36:40 +00:00
Log the container name and id
This commit is contained in:
@@ -141,6 +141,9 @@ func ListContainers(socketPath string, enforceNetworkValidation bool, containerN
|
|||||||
|
|
||||||
var dockerContainers []Container
|
var dockerContainers []Container
|
||||||
for _, c := range containers {
|
for _, c := range containers {
|
||||||
|
// Short ID like docker ps
|
||||||
|
shortId := c.ID[:12]
|
||||||
|
|
||||||
// Get container name (remove leading slash)
|
// Get container name (remove leading slash)
|
||||||
name := ""
|
name := ""
|
||||||
if len(c.Names) > 0 {
|
if len(c.Names) > 0 {
|
||||||
@@ -169,7 +172,7 @@ func ListContainers(socketPath string, enforceNetworkValidation bool, containerN
|
|||||||
// Inspect the container to get detailed network information
|
// Inspect the container to get detailed network information
|
||||||
containerInfo, err := cli.ContainerInspect(ctx, c.ID)
|
containerInfo, err := cli.ContainerInspect(ctx, c.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Debug("Failed to inspect container %s for network info: %v", c.ID[:12], err)
|
logger.Debug("Failed to inspect container %s (%s) for network info: %v", shortId, name, err)
|
||||||
// Continue without network info if inspection fails
|
// Continue without network info if inspection fails
|
||||||
} else {
|
} else {
|
||||||
// Only containers within the host container network will be returned
|
// Only containers within the host container network will be returned
|
||||||
@@ -209,13 +212,13 @@ func ListContainers(socketPath string, enforceNetworkValidation bool, containerN
|
|||||||
|
|
||||||
// Don't continue returning this container if not in the host container network(s)
|
// Don't continue returning this container if not in the host container network(s)
|
||||||
if enforceNetworkValidation && !isInHostContainerNetwork {
|
if enforceNetworkValidation && !isInHostContainerNetwork {
|
||||||
logger.Debug("container not found within the host container network, skipping: %s", name)
|
logger.Debug("Container not found within the host container network, skipping: %s (%s)", shortId, name)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dockerContainer := Container{
|
dockerContainer := Container{
|
||||||
ID: c.ID[:12], // Show short ID like docker ps
|
ID: shortId,
|
||||||
Name: name,
|
Name: name,
|
||||||
Image: c.Image,
|
Image: c.Image,
|
||||||
State: c.State,
|
State: c.State,
|
||||||
|
|||||||
Reference in New Issue
Block a user