Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

make the service example work #346

Merged
merged 2 commits into from

4 participants

Sridhar Ratnakumar Jérôme Petazzoni Bryan Helmig Solomon Hykes
Sridhar Ratnakumar

issue #98 suggests that connecting to localhost (which hostname may resolve to) will not work.

srid added some commits
Sridhar Ratnakumar srid make the service example work
issue #98 requires connecting to localhost (which `hostname` may resolve to) will not work.
27feba4
Sridhar Ratnakumar srid sync with README 9875a9b
Bryan Helmig

+1 Helped me, $(hostname) didn't work.

Solomon Hykes shykes merged commit 0767916 into from
Sridhar Ratnakumar srid deleted the branch
Jérôme Petazzoni

I'm suggesting this instead:

ip -f inet addr show scope global | sed -n 's/.*inet \([^ /]*\)[ /].*/\1/p' | tail -n 1

This should list all the "global scope" IPV4 addresses (i.e. not 127.X.Y.Z, multicast, etc.); meaning that if someone doesn't have an address on eth0, it should work anyway. (That's the case with some high-end bare metal providers, where eth0 is part of a bond group, and doesn't hold an address by itself).

HTH,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 7, 2013
  1. Sridhar Ratnakumar

    make the service example work

    srid authored
    issue #98 requires connecting to localhost (which `hostname` may resolve to) will not work.
  2. Sridhar Ratnakumar

    sync with README

    srid authored
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 2 deletions.
  1. +3 −1 README.md
  2. +2 −1  docs/sources/commandline/basics.rst
4 README.md
View
@@ -183,7 +183,9 @@ JOB=$(docker run -d -p 4444 base /bin/nc -l -p 4444)
PORT=$(docker port $JOB 4444)
# 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
echo "Daemon received: $(docker logs $JOB)"
3  docs/sources/commandline/basics.rst
View
@@ -69,7 +69,8 @@ Expose a service on a TCP port
# 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.
- 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
echo "Daemon received: $(docker logs $JOB)"
Something went wrong with that request. Please try again.