All Projects → ruoshan → autoportforward

ruoshan / autoportforward

Licence: BSD-3-Clause license
Bidirectional port-forwarding for docker, podman and kubernetes

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to autoportforward

plasma-docker
Plasmoid for KDE Plasma to control docker containers
Stars: ✭ 38 (-86.52%)
Mutual labels:  podman
snc
Single Node Cluster creation scripts for OpenShift 4.x as used by CodeReady Containers
Stars: ✭ 84 (-70.21%)
Mutual labels:  podman
Molecule
Molecule aids in the development and testing of Ansible roles
Stars: ✭ 3,262 (+1056.74%)
Mutual labels:  podman
lede-dockerbuilder
A (container based) LEDE/OpenWrt image builder.
Stars: ✭ 53 (-81.21%)
Mutual labels:  podman
cni-plugins
CNI Plugins compatible with nftables
Stars: ✭ 29 (-89.72%)
Mutual labels:  podman
microk8s-kata-containers
Kata Containers with MicroK8s
Stars: ✭ 32 (-88.65%)
Mutual labels:  podman
gnome-shell-extension-containers
containers is a gnome-shell extension to manage linux container, run by podman
Stars: ✭ 40 (-85.82%)
Mutual labels:  podman
FullProxy
Bind and reverse connection based, SOCKS5, HTTP and PortForward based portable proxy
Stars: ✭ 22 (-92.2%)
Mutual labels:  portforward
podman-api-rs
Rust interface to Podman (libpod).
Stars: ✭ 37 (-86.88%)
Mutual labels:  podman
X11docker
Run GUI applications and desktops in docker and podman containers. Focus on security.
Stars: ✭ 3,797 (+1246.45%)
Mutual labels:  podman
infraform
Creating infrastructure and running applications using different platforms
Stars: ✭ 31 (-89.01%)
Mutual labels:  podman
cryostat
Secure JDK Flight Recorder management for containerized JVMs
Stars: ✭ 147 (-47.87%)
Mutual labels:  podman
udm-utilities
A collection of things I have made to make the Unifi Dream Machine more useful
Stars: ✭ 2,228 (+690.07%)
Mutual labels:  podman
simplenetes
The sns tool is used to manage the full life cycle of your Simplenetes clusters. It integrates with the Simplenetes Podcompiler project podc to compile pods.
Stars: ✭ 731 (+159.22%)
Mutual labels:  podman
Kind
Kubernetes IN Docker - local clusters for testing Kubernetes
Stars: ✭ 8,932 (+3067.38%)
Mutual labels:  podman
podman-macos
📦 Podman frontend for macOS
Stars: ✭ 576 (+104.26%)
Mutual labels:  podman
molecule-podman
Molecule Podman Driver allows use of podman as backend for testing.
Stars: ✭ 48 (-82.98%)
Mutual labels:  podman
distrobox
Use any linux distribution inside your terminal. Enable both backward and forward compatibility with software and freedom to use whatever distribution you’re more comfortable with. Mirror available at: https://gitlab.com/89luca89/distrobox
Stars: ✭ 4,371 (+1450%)
Mutual labels:  podman
Podman Compose
a script to run docker-compose.yml using podman
Stars: ✭ 2,414 (+756.03%)
Mutual labels:  podman
docker-suricata
A Suricata Docker image.
Stars: ✭ 120 (-57.45%)
Mutual labels:  podman

Auto-portforward (apf)

A handy tool to automatically set up proxies that expose the remote container's listening ports back to the local machine. Just like kubectl portforward or docker run -p LOCAL:REMOTE, but automatically discover and update the ports to be forwarded on the fly. apf can create listening ports in the container and forward them back as well.

I often find myself forgetting to add -p option when testing a docker image or missing to expose some other ports. Now I don't need to worry about that, I just run the following commands:

$ docker run -d --name redis redis

$ apf redis

*  ==> : Forwarding local listening ports to (==>) remote ports
*  <== : Forwarding to local ports from (<==) remote listening ports (use -r option)

Forwarding: [6379 ==> 6379]

apf will update the port list on the fly. So if you login to the container and start other server listening on different ports, it will dynamically update the local listeners.

For Kubernetes (hey, if you haven't heard of telepresence , please give it a try, it's way cooler than this project.):

$ kubectl run --image redis redis

$ apf -k default/redis
Forwarding: [6379 ==> 6379]

For Podman:

$ podman run --name redis docker.io/library/redis:latest

$ apf -p redis
Forwarding: [6379 ==> 6379]

Installation

First of all, apf requires a working docker / kubectl client setup, the client can connect to either local docker daemon / k8s cluster or remote.

You can either download the binary from the release artifacts or build it yourself.

# MacOS (Intel)
curl -L -O https://github.com/ruoshan/autoportforward/releases/latest/download/apf-mac
chmod +x apf-mac
mv apf-mac /usr/local/bin/apf

# MacOS (ARM)
curl -L -O https://github.com/ruoshan/autoportforward/releases/latest/download/apf-mac-arm64
chmod +x apf-mac-arm64
mv apf-mac-arm64 /usr/local/bin/apf

# Linux
curl -L -O https://github.com/ruoshan/autoportforward/releases/latest/download/apf-linux-x64
chmod +x apf-linux-x64
mv apf-linux-x64 /usr/local/bin/apf

To manually build it, clone the repo and run the build.sh script.

Usage

Expose all the listening ports in the container back to the local machine

# Docker
apf {container ID / name}

# Kubernetes
apf -k {namespace}/{pod name}

# Podman
apf -p {podman container ID / name}

Also expose local ports (8080,9090) to the container

# Docker
apf -r 8080,9090  {container ID / name}

# Kubernetes
apf -r 8080,9090 -k {namespace}/{pod name}

# Podman
apf -r 8080,9090 -p {podman container ID / name}

Limitations

  • 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.
  • For Kubernetes, the container must have tar installed.
  • If the container is run with readonly rootfs, apf won't work. (apf needs to copy a guest agent into the container)

Tips

  1. apf does not come with shell completion, but here is what I do to make it more handy:
# `brew install fzf`
alias ap='docker ps | grep -v "^CONTAINER ID" | fzf | awk "{print \$1}" | xargs -n 1 apf'
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].