Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@improbableone
Copy link
Contributor

@improbableone improbableone commented May 29, 2025

Community Contribution License Agreement

By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.

Description

This PR adds Docker socket integration to Newt, enabling remote inspection of Docker containers. This functionality allows Pangolin to query and retrieve information about Docker containers running on the Newt client side.

✨ What's New

  • Docker Socket Detection: Added ability to check if Docker socket is available at a specified path
  • Container Listing: Implemented comprehensive Docker container information retrieval including:
    • Container metadata (ID, name, image, state, status)
    • Port mappings and network configurations
    • Labels and creation timestamps
    • Detailed network information (IP addresses, gateways, DNS names, etc.)

🔧 Technical Changes

New Files

  • Docker client implementation with:
    • CheckSocket() function to verify Docker socket availability
    • ListContainers() function to retrieve comprehensive container information
    • Structured types for Container, Port, and Network data

Modified Files

  • main.go:

    • Added Docker socket path configuration via DOCKER_SOCKET environment variable
    • Implemented WebSocket handlers for newt/socket/check and newt/socket/fetch commands
    • Integrated Docker functionality into the main event loop
  • go.mod: Added Docker SDK dependencies:

    • github.com/docker/docker - Official Docker SDK for Go
    • Related dependencies for OpenTelemetry, HTTP connections, and container specifications

🔌 WebSocket API

Two new WebSocket message handlers:

  1. newt/socket/check: Responds with Docker socket availability status
  2. newt/socket/fetch: Returns detailed list of all Docker containers with full network information

🛠️ Configuration

  • Environment Variable: DOCKER_SOCKET (defaults to docker.sock)
  • Graceful fallback when Docker socket is not available
  • Timeout protection for Docker API calls (5-second timeout)
  • Non-blocking Docker operations that don't affect core Newt functionality

🎯 Use Cases

This enhancement enables Pangolin to:

  • Monitor Docker containers across remote Newt installations
  • Provide centralized container visibility and management
  • Support container-aware routing and proxy configurations
  • Enable future container orchestration features

How to test?

  • Start pangolin from the corresponding PR
  • Build newt and register it with pangolin
INFO: 2025/05/29 22:56:06 Received Docker socket check request
DEBUG: 2025/05/29 22:56:06 Docker socket is available at /var/run/docker.sock
INFO: 2025/05/29 22:56:06 Docker socket check response sent: available=true
INFO: 2025/05/29 22:56:09 Received Docker container fetch request
INFO: 2025/05/29 22:56:09 Docker container list sent, count: 7

@improbableone
Copy link
Contributor Author

Pangolin PR: fosrl/pangolin#802

@oschwartz10612 oschwartz10612 merged commit c2d3f00 into fosrl:dev Jun 3, 2025
@oschwartz10612
Copy link
Member

Thanks so much for this addition it is amazing! We are going to try to get it into the next release.

@improbableone improbableone deleted the hub-dev branch June 8, 2025 08:37
@improbableone improbableone restored the hub-dev branch June 8, 2025 08:37
@improbableone improbableone deleted the hub-dev branch June 8, 2025 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants