瀏覽代碼

Merge pull request #346 from srid/patch-2

make the service example work
Solomon Hykes 12 年之前
父節點
當前提交
0767916ade
共有 2 個文件被更改,包括 5 次插入2 次删除
  1. 3 1
      README.md
  2. 2 1
      docs/sources/commandline/basics.rst

+ 3 - 1
README.md

@@ -183,7 +183,9 @@ JOB=$(docker run -d -p 4444 base /bin/nc -l -p 4444)
 PORT=$(docker port $JOB 4444)
 PORT=$(docker port $JOB 4444)
 
 
 # Connect to the public port via the host's public address
 # Connect to the public port via the host's public address
-echo hello world | nc $(hostname) $PORT
+# Please note that because of how routing works connecting to localhost or 127.0.0.1 $PORT will not work.
+IP=$(ifconfig eth0 | perl -n -e 'if (m/inet addr:([\d\.]+)/g) { print $1 }')
+echo hello world | nc $IP $PORT
 
 
 # Verify that the network connection worked
 # Verify that the network connection worked
 echo "Daemon received: $(docker logs $JOB)"
 echo "Daemon received: $(docker logs $JOB)"

+ 2 - 1
docs/sources/commandline/basics.rst

@@ -69,7 +69,8 @@ Expose a service on a TCP port
 
 
   # Connect to the public port via the host's public address
   # Connect to the public port via the host's public address
   # Please note that because of how routing works connecting to localhost or 127.0.0.1 $PORT will not work.
   # Please note that because of how routing works connecting to localhost or 127.0.0.1 $PORT will not work.
-  echo hello world | nc $(hostname) $PORT
+  IP=$(ifconfig eth0 | perl -n -e 'if (m/inet addr:([\d\.]+)/g) { print $1 }')
+  echo hello world | nc $IP $PORT
 
 
   # Verify that the network connection worked
   # Verify that the network connection worked
   echo "Daemon received: $(docker logs $JOB)"
   echo "Daemon received: $(docker logs $JOB)"