Corrects the TCP section of the basics use
| ... | ... |
@@ -138,22 +138,19 @@ Listing all running containers |
| 138 | 138 |
|
| 139 | 139 |
sudo docker ps |
| 140 | 140 |
|
| 141 |
-Expose a service on a TCP port |
|
| 141 |
+Bind a service on a TCP port |
|
| 142 | 142 |
------------------------------ |
| 143 | 143 |
|
| 144 | 144 |
.. code-block:: bash |
| 145 | 145 |
|
| 146 |
- # Expose port 4444 of this container, and tell netcat to listen on it |
|
| 146 |
+ # Bind port 4444 of this container, and tell netcat to listen on it |
|
| 147 | 147 |
JOB=$(sudo docker run -d -p 4444 ubuntu:12.10 /bin/nc -l 4444) |
| 148 | 148 |
|
| 149 | 149 |
# Which public port is NATed to my container? |
| 150 | 150 |
PORT=$(sudo docker port $JOB 4444 | awk -F: '{ print $2 }')
|
| 151 | 151 |
|
| 152 |
- # Connect to the public port via the host's public address |
|
| 153 |
- # Please note that because of how routing works connecting to localhost or 127.0.0.1 $PORT will not work. |
|
| 154 |
- # Replace *eth0* according to your local interface name. |
|
| 155 |
- IP=$(ip -o -4 addr list eth0 | perl -n -e 'if (m{inet\s([\d\.]+)\/\d+\s}xms) { print $1 }')
|
|
| 156 |
- echo hello world | nc $IP $PORT |
|
| 152 |
+ # Connect to the public port |
|
| 153 |
+ echo hello world | nc 127.0.0.1 $PORT |
|
| 157 | 154 |
|
| 158 | 155 |
# Verify that the network connection worked |
| 159 | 156 |
echo "Daemon received: $(sudo docker logs $JOB)" |
| ... | ... |
@@ -183,4 +180,3 @@ You now have a image state from which you can create new instances. |
| 183 | 183 |
|
| 184 | 184 |
Read more about :ref:`working_with_the_repository` or continue to the |
| 185 | 185 |
complete :ref:`cli` |
| 186 |
- |