Skip to content

Instantly share code, notes, and snippets.

@addisonj
Created February 17, 2014 23:41
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 addisonj/9061565 to your computer and use it in GitHub Desktop.
Save addisonj/9061565 to your computer and use it in GitHub Desktop.
Docker run comand
^C^Croot@codetrain-base:~# docker run -i -t -p 3000:3000 ubuntu /bin/bash
root@7c761d543db3:/# nc -kl 3000 &
[1] 9
root@7c761d543db3:/# echo "hello" | nc 192.168.133.128 3000
hello
root@7c761d543db3:/# ifconfig
eth0 Link encap:Ethernet HWaddr 96:81:71:3a:55:8d
inet addr:172.17.0.3 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::9481:71ff:fe3a:558d/64 Scope:Link
UP BROADCAST RUNNING MTU:1500 Metric:1
RX packets:22 errors:0 dropped:0 overruns:0 frame:0
TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1498 (1.4 KB) TX bytes:1180 (1.1 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
[debug] network.go:393 Acquiring 0.0.0.0:3000
[DEBUG] [iptables]: /sbin/iptables, [-t nat -A DOCKER -p tcp -d 0/0 --dport 3000 ! -i docker0 -j DNAT --to-destination 172.17.0.3:3000]
[debug] container.go:1135 Allocate port: 0.0.0.0:3000/tcp->3000
[debug] tcp_proxy.go:80 Starting proxy on tcp/[::]:3000 for tcp/172.17.0.3:3000
[debug] container.go:329 startPty: begin of stdout pipe
[debug] container.go:340 startPty: begin of stdin pipe
[debug] container.go:1187 monitor: waiting for container 7c761d543db398e95cad6e264acb31dd2622c96a59e0e1716213c385429233c2 using cmd.Wait
[debug] container.go:782 Waiting for the container to start (running: true): state: STOPPED
[debug] container.go:790 Container running: true
[/var/lib/docker|eda9e755] -job start(7c761d543db398e95cad6e264acb31dd2622c96a59e0e1716213c385429233c2) = OK (0)
[debug] api.go:1038 Calling POST /containers/{name:.*}/resize
2014/02/17 15:37:56 POST /v1.8/containers/7c761d543db398e95cad6e264acb31dd2622c96a59e0e1716213c385429233c2/resize?h=73&w=289
[/var/lib/docker|eda9e755] +job resize(7c761d543db398e95cad6e264acb31dd2622c96a59e0e1716213c385429233c2, 73, 289)
[/var/lib/docker|eda9e755] -job resize(7c761d543db398e95cad6e264acb31dd2622c96a59e0e1716213c385429233c2, 73, 289) = OK (0)
[debug] tcp_proxy.go:52 Forwarding traffic between tcp/172.17.0.3:57240 and tcp/172.17.0.3:3000
[debug] tcp_proxy.go:74 6 bytes transferred between tcp/172.17.0.3:57240 and tcp/172.17.0.3:3000
root@codetrain-base:~# iptables-save
# Generated by iptables-save v1.4.12 on Mon Feb 17 15:38:16 2014
*filter
:INPUT ACCEPT [1684:120145]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [1076:140803]
-A FORWARD -i docker0 -o docker0 -j ACCEPT
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
COMMIT
# Completed on Mon Feb 17 15:38:16 2014
# Generated by iptables-save v1.4.12 on Mon Feb 17 15:38:16 2014
*nat
:PREROUTING ACCEPT [1:241]
:INPUT ACCEPT [1:241]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:DOCKER - [0:0]
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
-A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
-A POSTROUTING -s 10.0.3.0/24 ! -d 10.0.3.0/24 -j MASQUERADE
-A POSTROUTING -s 172.17.0.0/16 ! -d 172.17.0.0/16 -j MASQUERADE
-A DOCKER ! -i docker0 -p tcp -m tcp --dport 3000 -j DNAT --to-destination 172.17.0.3:3000
COMMIT
# Completed on Mon Feb 17 15:38:16 2014
root@codetrain-base:~# ifconfig
docker0 Link encap:Ethernet HWaddr 16:a2:8d:b1:e2:89
inet addr:172.17.42.1 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::58eb:9cff:fe3a:92b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:40 errors:0 dropped:0 overruns:0 frame:0
TX packets:21 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2350 (2.3 KB) TX bytes:1532 (1.5 KB)
eth0 Link encap:Ethernet HWaddr 00:0c:29:45:01:a9
inet addr:192.168.133.128 Bcast:192.168.133.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe45:1a9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1784 errors:0 dropped:0 overruns:0 frame:0
TX packets:1121 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:155600 (155.6 KB) TX bytes:162621 (162.6 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:39 errors:0 dropped:0 overruns:0 frame:0
TX packets:39 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2236 (2.2 KB) TX bytes:2236 (2.2 KB)
lxcbr0 Link encap:Ethernet HWaddr f2:9e:a3:7d:2a:e1
inet addr:10.0.3.1 Bcast:10.0.3.255 Mask:255.255.255.0
inet6 addr: fe80::f09e:a3ff:fe7d:2ae1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:1070 (1.0 KB)
vethI0nxP8 Link encap:Ethernet HWaddr 16:a2:8d:b1:e2:89
inet6 addr: fe80::14a2:8dff:feb1:e289/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:19 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:632 (632.0 B) TX bytes:1326 (1.3 KB)
vethW6lXHt Link encap:Ethernet HWaddr c6:34:c9:68:50:ec
inet6 addr: fe80::c434:c9ff:fe68:50ec/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:16 errors:0 dropped:0 overruns:0 frame:0
TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1094 (1.0 KB) TX bytes:1366 (1.3 KB)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment