Skip to content

Instantly share code, notes, and snippets.

@danguita
Last active June 26, 2020 16:43
Show Gist options
  • Save danguita/21e6f9050ef556e5e2177d8407f5a72e to your computer and use it in GitHub Desktop.
Save danguita/21e6f9050ef556e5e2177d8407f5a72e to your computer and use it in GitHub Desktop.
Docker Machine SSH tunneling

As described on the Docker Machine SSH reference, the docker-machine CLI invokes the standard OpenSSH client so we can use the common SSH tunneling syntax here. The following command will forward port 3000 from the default machine to localhost on your host computer's loopback interface. Using 0.0.0.0 as bind_address will make it bind to all interfaces:

$ docker-machine ssh default -L 0.0.0.0:3000:localhost:3000

So, the container running at machine's port 3000 can be reached through localhost:3000 or any of your interfaces' IP (i.e. 192.168.1.10:3000). That'd be useful to access your containerized services from other devices in your LAN.

@danguita

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment