Last active
December 28, 2015 22:19
-
-
Save tracker1/7570724 to your computer and use it in GitHub Desktop.
DockerCheatSheet - update for docker 0.7.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
base image tracker1/nodejs -- ubuntu 12.04 w/ python 2.7, build tools and nodejs 0.10.22 | |
build docker app, from app dir :tagname | |
sudo docker build -t tracker1/nodejs-demo:1 . | |
run docker app in bg / -p ### will create random forward for port X | |
-d is daemon mode, or & at the end for background | |
sudo docker run -d -name demo1 tracker1/nodejs-demo:1 | |
sudo docker run -name demo1 tracker1/nodejs-demo:1 & | |
sudo docker kill demo1 | |
sudo docker restart demo1 | |
GET IP FOR CONTAINER $CID == | |
sudo docker inspect $CID | grep IPAddress | cut -d '"' -f 4 | |
LIST FORWARD FOR DOCKER | |
sudo iptables -t nat -L DOCKER | |
LIST EXISTING FORWARD RULES (to get position) | |
sudo iptables -t nat -L PREROUTING | |
CREATE FORWARD RULE | |
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2323 -j DNAT --to 172.17.0.18:2323 | |
REPLACE EXISTING FORWARD RULE ... -R {CHAIN} {rulenum-1-based} | |
sudo iptables -t nat -R PREROUTING 2 -i eth0 -p tcp --dport 2323 -j DNAT --to 172.17.0.19:2323 | |
DELETE EXISTING FORWARD RULE ... -D {CHAIN} {rulnum-1-based} | |
sudo iptables -t nat -D PREROUTING 2 | |
/// | |
michaelr@ubuntu:~$ sudo iptables -t nat -A DOCKER -p tcp --dport 4001 -j DNAT --to-destination 127.0.0.1:4001 | |
michaelr@ubuntu:~$ sudo iptables -t nat -L DOCKER --line-numbers | |
Chain DOCKER (2 references) | |
num target prot opt source destination | |
1 DNAT tcp -- anywhere anywhere tcp dpt:4001 to:127.0.0.1:4001 | |
michaelr@ubuntu:~$ sudo iptables -t nat -D DOCKER 1 | |
michaelr@ubuntu:~$ sudo iptables -t nat -L DOCKER --line-numbers | |
Chain DOCKER (2 references) | |
num target prot opt source destination | |
michaelr@ubuntu:~$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment