[PR #97] [MERGED] feat: docker socket protocol #120

Closed
opened 2025-11-19 07:14:27 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fosrl/newt/pull/97
Author: @Nemental
Created: 7/30/2025
Status: Merged
Merged: 8/30/2025
Merged by: @oschwartz10612

Base: mainHead: feat/docker-socket-protocol


📝 Commits (4)

  • 42dfb6b feat: add type and function for docker endpoint parsing
  • a79dccc feat: checksocket protocol support
  • e9dbfb2 fix: remove hardcoded protocol from socket path
  • a9d8ec0 docs: update docker socket part

📊 Changes

3 files changed (+63 additions, -10 deletions)

View changed files

📝 README.md (+23 -2)
📝 docker/client.go (+39 -7)
📝 main.go (+1 -1)

📄 Description

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

Closes #62

This PR enhances Docker socket path handling in Newt by adding support for protocol-prefixed socket paths, such as:

The new parseDockerHost function extracts the protocol and address, allowing CheckSocket to validate reachability for multiple Docker API endpoints, not just local UNIX sockets.

How to test?

TCP Example with linuxserver/docker-socket-proxy

  1. Add socket proxy service to your newt-compose
  • Example snippet
      socket-proxy:
        image: ghcr.io/linuxserver/socket-proxy:3.2.3
        restart: unless-stopped
        environment:
          CONTAINERS: 1
          EVENTS: 1
          INFO: 1
          NETWORKS: 1
          PING: 1
          VERSION: 1
        volumes:
          - /var/run/docker.sock:/var/run/docker.sock:ro
        read_only: true
        tmpfs:
          - /run
        networks:
          - pangolin
    
  1. Run Newt with different socket protocols
  • Command Argument:
        command:
          - --docker-socket tcp://socket-proxy:2375
    
  • Environment Variable
        environment:
          DOCKER_SOCKET: tcp://socket-proxy:2375
    
  1. Trigger the socket check from Pangolin
  • Navigate to "Resources"
  • Edit a Resource
  • Targets Configuration -> IP / Hostname -> View Docker Containers
  • Observe logs for messages like:
    • Pangolin
      [info]: Docker socket availability for Newt id12345abc: available=true, socketPath=http://socket-proxy:2375
      
    • Newt
      DEBUG: 2025/07/30 12:41:15 Received Docker socket check request
      DEBUG: 2025/07/30 12:41:15 Docker reachable via tcp at socket-proxy:2375
      DEBUG: 2025/07/30 12:41:15 Sending message: newt/socket/status, data: map[available:true socketPath:http://socket-proxy:2375]
      INFO: 2025/07/30 12:41:15 Docker socket check response sent: available=true
      
  1. Verify container listing loads successfully in the Pangolin UI.

  2. Optionally, test with invalid or unreachable paths to ensure graceful error handling.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/fosrl/newt/pull/97 **Author:** [@Nemental](https://github.com/Nemental) **Created:** 7/30/2025 **Status:** ✅ Merged **Merged:** 8/30/2025 **Merged by:** [@oschwartz10612](https://github.com/oschwartz10612) **Base:** `main` ← **Head:** `feat/docker-socket-protocol` --- ### 📝 Commits (4) - [`42dfb6b`](https://github.com/fosrl/newt/commit/42dfb6b3d85a3d9f7bcfc7d6023e58e148778877) feat: add type and function for docker endpoint parsing - [`a79dccc`](https://github.com/fosrl/newt/commit/a79dccc0e497d3ac0cb56dc17f74b12599fb9419) feat: checksocket protocol support - [`e9dbfb2`](https://github.com/fosrl/newt/commit/e9dbfb239b045671a76f864ac9cf328ec294751b) fix: remove hardcoded protocol from socket path - [`a9d8ec0`](https://github.com/fosrl/newt/commit/a9d8ec0b1e36bfb1da0e13000fe656590774bd07) docs: update docker socket part ### 📊 Changes **3 files changed** (+63 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+23 -2) 📝 `docker/client.go` (+39 -7) 📝 `main.go` (+1 -1) </details> ### 📄 Description ## 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 Closes #62 This PR enhances Docker socket path handling in Newt by adding support for protocol-prefixed socket paths, such as: - unix:///var/run/docker.sock - tcp://localhost:2375 - http://127.0.0.1:2375 - ssh://user@host The new parseDockerHost function extracts the protocol and address, allowing CheckSocket to validate reachability for multiple Docker API endpoints, not just local UNIX sockets. ## How to test? ### TCP Example with [linuxserver/docker-socket-proxy](https://github.com/linuxserver/docker-socket-proxy) 1. **Add socket proxy service to your newt-compose** * Example snippet ```yaml socket-proxy: image: ghcr.io/linuxserver/socket-proxy:3.2.3 restart: unless-stopped environment: CONTAINERS: 1 EVENTS: 1 INFO: 1 NETWORKS: 1 PING: 1 VERSION: 1 volumes: - /var/run/docker.sock:/var/run/docker.sock:ro read_only: true tmpfs: - /run networks: - pangolin ``` 2. **Run Newt with different socket protocols** * Command Argument: ```yaml command: - --docker-socket tcp://socket-proxy:2375 ``` * Environment Variable ```yaml environment: DOCKER_SOCKET: tcp://socket-proxy:2375 ``` 3. **Trigger the socket check from Pangolin** * Navigate to "Resources" * Edit a Resource * Targets Configuration -> IP / Hostname -> View Docker Containers * Observe logs for messages like: * Pangolin ``` [info]: Docker socket availability for Newt id12345abc: available=true, socketPath=http://socket-proxy:2375 ``` * Newt ``` DEBUG: 2025/07/30 12:41:15 Received Docker socket check request DEBUG: 2025/07/30 12:41:15 Docker reachable via tcp at socket-proxy:2375 DEBUG: 2025/07/30 12:41:15 Sending message: newt/socket/status, data: map[available:true socketPath:http://socket-proxy:2375] INFO: 2025/07/30 12:41:15 Docker socket check response sent: available=true ``` 4. **Verify container listing loads successfully in the Pangolin UI.** 5. **Optionally, test with invalid or unreachable paths to ensure graceful error handling.** --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-19 07:14:27 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/newt#120