title: Port forwarding with Elastic docker image
body: <p>I'm trying to test docker out with <a href="https://hub.docker.com/_/elasticsearch/" rel="nofollow">this docker image</a>. Things should be straight forward. But it isn't.</p>
  
  <p>I ran this command to start the container:</p>
  
  <pre><code>sudo docker run -d -p 9200:9200 -p 9300:9300 elasticsearch -Des.node.name="ElasticTestNode"
  </code></pre>
  
  <p>Then I tried to run this command in my host machine:</p>
  
  <pre><code># curl -XPUT "http://localhost:9200/movies/movie/3" -d'
  {
      "title": "To Kill a Mockingbird",
      "director": "Robert Mulligan",
      "year": 1962,
      "genres": ["Crime", "Drama", "Mystery"]
  }'
  </code></pre>
  
  <p>I was expecting to see some kind of successful message. Instead, the command <strong>simply stuck</strong>. No output and not stopping at all. I have to Ctrl-X to quit.</p>
  
  <p>Ran out of idea, I started a bash shell inside the docker and tested:</p>
  
  <pre><code>sudo sudo docker exec -i -t some-docker-id /bin/bash
  root@somehash:/usr/share/elasticsearch# curl -XPUT "http://localhost:9200/movies/movie/3" -d'
  {
      "title": "To Kill a Mockingbird",
      "director": "Robert Mulligan",
      "year": 1962,
      "genres": ["Crime", "Drama", "Mystery"]
  }'
  {"_index":"movies","_type":"movie","_id":"3","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}root@somehash:/usr/share/elasticsearch#
  </code></pre>
  
  <p>And it was a success. What have I done wrong?</p>
  
  <p><strong>Updates:</strong> Tried another command on my host machine:</p>
  
  <pre><code>$ curl -XPUT -v "http://localhost:9200/movies/movie/3" -d'
  {
      "title": "To Kill a Mockingbird",
      "director": "Robert Mulligan",
      "year": 1962,
      "genres": ["Crime", "Drama", "Mystery"]
  }'
  *   Trying 127.0.0.1...
  * Connected to localhost (127.0.0.1) port 9200 (#0)
  &gt; PUT /movies/movie/3 HTTP/1.1
  &gt; Host: localhost:9200
  &gt; User-Agent: curl/7.43.0
  &gt; Accept: */*
  &gt; Content-Length: 139
  &gt; Content-Type: application/x-www-form-urlencoded
  &gt; 
  * upload completely sent off: 139 out of 139 bytes
  </code></pre>
  
  <p>Stuck here...</p>
  
  <pre><code># sudo docker logs docker-id
  [2016-09-28 11:52:16,630][INFO ][node                     ] [ElasticTestNode] version[2.4.0], pid[1], build[ce9f0c7/2016-08-29T09:14:17Z]
  [2016-09-28 11:52:16,631][INFO ][node                     ] [ElasticTestNode] initializing ...
  [2016-09-28 11:52:17,202][INFO ][plugins                  ] [ElasticTestNode] modules [reindex, lang-expression, lang-groovy], plugins [], sites []
  [2016-09-28 11:52:17,219][INFO ][env                      ] [ElasticTestNode] using [1] data paths, mounts [[/usr/share/elasticsearch/data (/dev/sda8)]], net usable_space [5.4gb], net total_space [19.5gb], spins? [possibly], types [ext4]
  [2016-09-28 11:52:17,219][INFO ][env                      ] [ElasticTestNode] heap size [990.7mb], compressed ordinary object pointers [true]
  [2016-09-28 11:52:18,816][INFO ][node                     ] [ElasticTestNode] initialized
  [2016-09-28 11:52:18,816][INFO ][node                     ] [ElasticTestNode] starting ...
  [2016-09-28 11:52:18,877][INFO ][transport                ] [ElasticTestNode] publish_address {172.17.0.22:9300}, bound_addresses {[::]:9300}
  [2016-09-28 11:52:18,881][INFO ][discovery                ] [ElasticTestNode] elasticsearch/LCo5k0dARimsWFXjN1Yu0A
  [2016-09-28 11:52:21,915][INFO ][cluster.service          ] [ElasticTestNode] new_master {ElasticTestNode}{LCo5k0dARimsWFXjN1Yu0A}{172.17.0.22}{172.17.0.22:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
  [2016-09-28 11:52:21,924][INFO ][http                     ] [ElasticTestNode] publish_address {172.17.0.22:9200}, bound_addresses {[::]:9200}
  [2016-09-28 11:52:21,925][INFO ][node                     ] [ElasticTestNode] started
  [2016-09-28 11:52:21,960][INFO ][gateway                  ] [ElasticTestNode] recovered [0] indices into cluster_state
  </code></pre>