{"id":13548633,"url":"https://github.com/ruoshan/autoportforward","last_synced_at":"2026-01-18T09:24:25.094Z","repository":{"id":43268322,"uuid":"442471724","full_name":"ruoshan/autoportforward","owner":"ruoshan","description":"Bidirectional port-forwarding for docker, podman and kubernetes","archived":false,"fork":false,"pushed_at":"2022-05-07T08:22:59.000Z","size":35,"stargazers_count":286,"open_issues_count":1,"forks_count":8,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-02T21:37:44.113Z","etag":null,"topics":["docker","kubernetes","podman","portforward"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ruoshan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-28T13:27:03.000Z","updated_at":"2025-01-26T11:17:44.000Z","dependencies_parsed_at":"2022-09-08T00:01:53.736Z","dependency_job_id":null,"html_url":"https://github.com/ruoshan/autoportforward","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/ruoshan/autoportforward","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruoshan%2Fautoportforward","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruoshan%2Fautoportforward/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruoshan%2Fautoportforward/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruoshan%2Fautoportforward/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruoshan","download_url":"https://codeload.github.com/ruoshan/autoportforward/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruoshan%2Fautoportforward/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28490395,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T23:55:29.509Z","status":"ssl_error","status_checked_at":"2026-01-16T23:55:29.108Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","kubernetes","podman","portforward"],"created_at":"2024-08-01T12:01:12.684Z","updated_at":"2026-01-17T00:40:13.720Z","avatar_url":"https://github.com/ruoshan.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Auto-portforward (apf)\n\nA handy tool to automatically set up proxies that expose the remote container's listening ports\nback to the local machine. Just like `kubectl portforward` or `docker run -p LOCAL:REMOTE`, but\nautomatically discover and update the ports to be forwarded on the fly. `apf` can create listening\nports in the container and forward them back as well.\n\nI often find myself forgetting to add `-p` option when testing a docker image or missing to\nexpose some other ports. Now I don't need to worry about that, I just run the following commands:\n\n```\n$ docker run -d --name redis redis\n\n$ apf redis\n\n*  ==\u003e : Forwarding local listening ports to (==\u003e) remote ports\n*  \u003c== : Forwarding to local ports from (\u003c==) remote listening ports (use -r option)\n\nForwarding: [6379 ==\u003e 6379]\n```\n\n`apf` will update the port list on the fly. So if you login to the container and start other\nserver listening on different ports, it will dynamically update the local listeners.\n\nFor Kubernetes (hey, if you haven't heard of [telepresence](telepresence.io) , please give it a try, it's way cooler than this project.):\n\n```\n$ kubectl run --image redis redis\n\n$ apf -k default/redis\nForwarding: [6379 ==\u003e 6379]\n```\n\nFor Podman:\n\n```\n$ podman run --name redis docker.io/library/redis:latest\n\n$ apf -p redis\nForwarding: [6379 ==\u003e 6379]\n```\n\n## Installation\n\nFirst of all, `apf` requires a working `docker` / `kubectl` client setup, the client can connect to either\nlocal docker daemon / k8s cluster or remote.\n\nYou can either download the binary from the release artifacts or build it yourself.\n\n```\n# MacOS (Intel)\ncurl -L -O https://github.com/ruoshan/autoportforward/releases/latest/download/apf-mac\nchmod +x apf-mac\nmv apf-mac /usr/local/bin/apf\n\n# MacOS (ARM)\ncurl -L -O https://github.com/ruoshan/autoportforward/releases/latest/download/apf-mac-arm64\nchmod +x apf-mac-arm64\nmv apf-mac-arm64 /usr/local/bin/apf\n\n# Linux\ncurl -L -O https://github.com/ruoshan/autoportforward/releases/latest/download/apf-linux-x64\nchmod +x apf-linux-x64\nmv apf-linux-x64 /usr/local/bin/apf\n```\n\nTo manually build it, clone the repo and run the `build.sh` script.\n\n## Usage\n\n### Expose all the listening ports in the container back to the local machine\n\n```\n# Docker\napf {container ID / name}\n\n# Kubernetes\napf -k {namespace}/{pod name}\n\n# Podman\napf -p {podman container ID / name}\n```\n\n### Also expose local ports (8080,9090) to the container\n\n```\n# Docker\napf -r 8080,9090  {container ID / name}\n\n# Kubernetes\napf -r 8080,9090 -k {namespace}/{pod name}\n\n# Podman\napf -r 8080,9090 -p {podman container ID / name}\n```\n\n\n## Limitations\n\n- Currently, `apf` only supports containers of the same CPU arch of your host machine. For other arch, you can do a custom build by tweaking the `build.sh` script.\n- For Kubernetes, the container must have `tar` installed.\n- If the container is run with readonly rootfs, apf won't work. (apf needs to copy a guest agent into the container)\n\n## Tips\n\n1. apf does not come with shell completion, but here is what I do to make it more handy:\n\n```\n# `brew install fzf`\nalias ap='docker ps | grep -v \"^CONTAINER ID\" | fzf | awk \"{print \\$1}\" | xargs -n 1 apf'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruoshan%2Fautoportforward","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruoshan%2Fautoportforward","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruoshan%2Fautoportforward/lists"}