{"id":28758786,"url":"https://github.com/hypnguyen1209/docker-container-socks","last_synced_at":"2025-08-02T01:36:18.706Z","repository":{"id":297367253,"uuid":"996555718","full_name":"hypnguyen1209/docker-container-socks","owner":"hypnguyen1209","description":"A program that creates a SOCKS5 proxy server to route all traffic through a Docker container's network namespace","archived":false,"fork":false,"pushed_at":"2025-06-05T06:01:01.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-05T07:15:52.620Z","etag":null,"topics":["docker","docker-container","socks5-server"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hypnguyen1209.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-05T05:51:01.000Z","updated_at":"2025-06-05T06:01:02.000Z","dependencies_parsed_at":"2025-06-05T07:17:11.387Z","dependency_job_id":"48e67d72-2ef5-458e-a578-b3e1b6a9ef1a","html_url":"https://github.com/hypnguyen1209/docker-container-socks","commit_stats":null,"previous_names":["hypnguyen1209/docker-container-socks"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/hypnguyen1209/docker-container-socks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypnguyen1209%2Fdocker-container-socks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypnguyen1209%2Fdocker-container-socks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypnguyen1209%2Fdocker-container-socks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypnguyen1209%2Fdocker-container-socks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hypnguyen1209","download_url":"https://codeload.github.com/hypnguyen1209/docker-container-socks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypnguyen1209%2Fdocker-container-socks/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260288454,"owners_count":22986669,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-container","socks5-server"],"created_at":"2025-06-17T04:09:46.533Z","updated_at":"2025-06-17T04:09:47.091Z","avatar_url":"https://github.com/hypnguyen1209.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker Container SOCKS\n\nA Go program that creates a SOCKS5 proxy server to route all traffic through a Docker container's network namespace.\n\n## Features\n\n- Creates a SOCKS5 proxy server that routes traffic through a Docker container's network\n- Supports both container names and container IDs\n- Configurable listen address (supports all interfaces or localhost only)\n- Custom Docker socket path support\n- Network namespace switching for proper traffic routing\n\n## Requirements\n\n- Go 1.21+\n- Docker running\n- Root privileges (required for network namespace operations)\n- Linux (uses netlink and netns libraries)\n\n## Installation\n\n```bash\n# Clone or navigate to the project directory\ncd docker-container-socks\n\n# Download dependencies\ngo mod tidy\n\n# Build the program\ngo build -o docker-container-socks main.go\n```\n\n## Usage\n\n```bash\n# Basic usage with container name\nsudo ./docker-container-socks -container mycontainer\n\n# Specify container ID and custom listen address\nsudo ./docker-container-socks -container abc123def456 -listen :8080\n\n# Listen on localhost only\nsudo ./docker-container-socks -container mycontainer -listen 127.0.0.1:1080\n\n# Use custom Docker socket path\nsudo ./docker-container-socks -container mycontainer -unix /custom/path/docker.sock -listen :9090\n```\n\n### Command Line Arguments\n\n- `-container` (required): Container name or container ID\n- `-listen` (optional): Listen address for SOCKS5 proxy server (default: `:8080`)\n  - `:8080` - Listen on all interfaces, port 8080\n  - `127.0.0.1:1080` - Listen on localhost only, port 1080\n  - `0.0.0.0:9090` - Listen on all interfaces, port 9090\n- `-unix` (optional): Path to Docker socket (default: `/var/run/docker.sock`)\n\n## How It Works\n\n1. **Container Discovery**: The program connects to the Docker API and inspects the specified container to get its network information and process ID (PID).\n\n2. **Network Namespace**: It uses the container's PID to access its network namespace using Linux netns functionality.\n\n3. **SOCKS5 Proxy**: A SOCKS5 proxy server is created that intercepts connection requests.\n\n4. **Traffic Routing**: For each connection through the proxy, the program:\n   - Switches to the container's network namespace\n   - Establishes the connection from within that namespace\n   - Routes the traffic through the container's network stack\n   - Switches back to the original namespace\n\n## Example Use Cases\n\n- Route web scraping through a VPN container\n- Access services through a container with specific network configuration\n- Test applications as if running from within a container's network\n- Bypass network restrictions using a proxy container\n\n## Security Notes\n\n- This program requires root privileges to manipulate network namespaces\n- All traffic through the proxy will have the same network identity as the target container\n- Ensure the target container is trusted and secure\n\n## Testing\n\nYou can test the proxy with curl:\n\n```bash\n# Start the proxy (in another terminal)\nsudo ./docker-container-socks -container mycontainer -listen :1080\n\n# Test with curl\ncurl --socks5 127.0.0.1:1080 http://httpbin.org/ip\n```\n\n## Troubleshooting\n\n- **Permission denied**: Make sure to run with sudo/root privileges\n- **Container not found**: Verify the container name/ID and that it's running\n- **Network namespace errors**: Ensure the container is running and accessible\n- **Docker socket errors**: Check that Docker is running and the socket path is correct\n\n## Dependencies\n\n- `github.com/docker/docker` - Docker API client\n- `github.com/things-go/go-socks5` - SOCKS5 server implementation\n- `github.com/vishvananda/netlink` - Linux netlink library\n- `github.com/vishvananda/netns` - Network namespace utilities\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypnguyen1209%2Fdocker-container-socks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhypnguyen1209%2Fdocker-container-socks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypnguyen1209%2Fdocker-container-socks/lists"}