Skip to content

Instantly share code, notes, and snippets.

@anokun7
Created August 21, 2015 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anokun7/180346d8c4bf4a56d8f0 to your computer and use it in GitHub Desktop.
Save anokun7/180346d8c4bf4a56d8f0 to your computer and use it in GitHub Desktop.
To expose a port on a running container
# Run this on the docker host (of course)
# Here I am exposing port 8080 on the container whose IPAddress is 172.17.0.113
#> as port 8888 on the docker host
# To get the container's IPAddress, use `docker inspect <containerid> | grep IPAddress
# To get the docker host's ip address and ssh into it, use:
# `docker-machine ssh $(docker-machine ls -q)`
iptables -t nat -A DOCKER -p tcp --dport 8888 -j DNAT --to-destination 172.17.0.113:8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment