Browse Source

Merge branch 'docs-example-fix' of git://github.com/faizkhan00/docker
merges #1402

Andy Rothfusz 12 years ago
parent
commit
7c03bd1e7a
1 changed files with 53 additions and 43 deletions
  1. 53 43
      docs/sources/examples/running_ssh_service.rst

+ 53 - 43
docs/sources/examples/running_ssh_service.rst

@@ -20,7 +20,7 @@ minutes and not entirely smooth, but gives you a good idea.
     <div style="margin-top:10px;">
       <iframe width="800" height="400" src="http://ascii.io/a/2637/raw" frameborder="0"></iframe>
     </div>
-	
+        
 You can also get this sshd container by using
 ::
 
@@ -33,47 +33,57 @@ The password is 'screencast'
 
 .. code-block:: bash
 
-	 # Hello! We are going to try and install openssh on a container and run it as a servic 
-	 # let's pull ubuntu to get a base ubuntu image. 
-	 $ docker pull ubuntu
-	 # I had it so it was quick
-	 # now let's connect using -i for interactive and with -t for terminal 
-	 # we execute /bin/bash to get a prompt.
-	 $ docker run -i -t ubuntu /bin/bash
-	 # now let's commit it 
-	 # which container was it?
-	 $ docker ps -a |more
-	 $ docker commit a30a3a2f2b130749995f5902f079dc6ad31ea0621fac595128ec59c6da07feea dhrp/sshd 
-	 # I gave the name dhrp/sshd for the container
-	 # now we can run it again 
-	 $ docker run -d dhrp/sshd /usr/sbin/sshd -D # D for daemon mode 
-	 # is it running?
-	 $ docker ps
-	 # yes!
-	 # let's stop it 
-	 $ docker stop 0ebf7cec294755399d063f4b1627980d4cbff7d999f0bc82b59c300f8536a562
-	 $ docker ps
-	 # and reconnect, but now open a port to it
-	 $ docker run -d -p 22 dhrp/sshd /usr/sbin/sshd -D 
-	 $ docker port b2b407cf22cf8e7fa3736fa8852713571074536b1d31def3fdfcd9fa4fd8c8c5 22
-	 # it has now given us a port to connect to
-	 # we have to connect using a public ip of our host
-	 $ hostname
-	 # *ifconfig* is deprecated, better use *ip addr show* now
-	 $ ifconfig
-	 $ ssh root@192.168.33.10 -p 49153
-	 # Ah! forgot to set root passwd
-	 $ docker commit b2b407cf22cf8e7fa3736fa8852713571074536b1d31def3fdfcd9fa4fd8c8c5 dhrp/sshd 
-	 $ docker ps -a
-	 $ docker run -i -t dhrp/sshd /bin/bash
-	 $ passwd
-	 $ exit
-	 $ docker commit 9e863f0ca0af31c8b951048ba87641d67c382d08d655c2e4879c51410e0fedc1 dhrp/sshd
-	 $ docker run -d -p 22 dhrp/sshd /usr/sbin/sshd -D
-	 $ docker port a0aaa9558c90cf5c7782648df904a82365ebacce523e4acc085ac1213bfe2206 22
-	 # *ifconfig* is deprecated, better use *ip addr show* now
-	 $ ifconfig
-	 $ ssh root@192.168.33.10 -p 49154
-	 # Thanks for watching, Thatcher thatcher@dotcloud.com
+         # Hello! We are going to try and install openssh on a container and run it as a servic 
+         # let's pull ubuntu to get a base ubuntu image. 
+         $ docker pull ubuntu
+         # I had it so it was quick
+         # now let's connect using -i for interactive and with -t for terminal 
+         # we execute /bin/bash to get a prompt.
+         $ docker run -i -t base /bin/bash
+         # yes! we are in!
+         # now lets install openssh
+         $ apt-get update
+         $ apt-get install openssh-server
+         # ok. lets see if we can run it.
+         $ which sshd
+         # we need to create priviledge separation directory
+         $ mkdir /var/run/sshd
+         $ /usr/sbin/sshd
+         $ exit
+         # now let's commit it 
+         # which container was it?
+         $ docker ps -a |more
+         $ docker commit a30a3a2f2b130749995f5902f079dc6ad31ea0621fac595128ec59c6da07feea dhrp/sshd 
+         # I gave the name dhrp/sshd for the container
+         # now we can run it again 
+         $ docker run -d dhrp/sshd /usr/sbin/sshd -D # D for daemon mode 
+         # is it running?
+         $ docker ps
+         # yes!
+         # let's stop it 
+         $ docker stop 0ebf7cec294755399d063f4b1627980d4cbff7d999f0bc82b59c300f8536a562
+         $ docker ps
+         # and reconnect, but now open a port to it
+         $ docker run -d -p 22 dhrp/sshd /usr/sbin/sshd -D 
+         $ docker port b2b407cf22cf8e7fa3736fa8852713571074536b1d31def3fdfcd9fa4fd8c8c5 22
+         # it has now given us a port to connect to
+         # we have to connect using a public ip of our host
+         $ hostname
+         # *ifconfig* is deprecated, better use *ip addr show* now
+         $ ifconfig
+         $ ssh root@192.168.33.10 -p 49153
+         # Ah! forgot to set root passwd
+         $ docker commit b2b407cf22cf8e7fa3736fa8852713571074536b1d31def3fdfcd9fa4fd8c8c5 dhrp/sshd 
+         $ docker ps -a
+         $ docker run -i -t dhrp/sshd /bin/bash
+         $ passwd
+         $ exit
+         $ docker commit 9e863f0ca0af31c8b951048ba87641d67c382d08d655c2e4879c51410e0fedc1 dhrp/sshd
+         $ docker run -d -p 22 dhrp/sshd /usr/sbin/sshd -D
+         $ docker port a0aaa9558c90cf5c7782648df904a82365ebacce523e4acc085ac1213bfe2206 22
+         # *ifconfig* is deprecated, better use *ip addr show* now
+         $ ifconfig
+         $ ssh root@192.168.33.10 -p 49154
+         # Thanks for watching, Thatcher thatcher@dotcloud.com