title: Why is are my published ports not working?
body: <p>I've created a docker image containing a rust application that responds to get requests on port 8000.  The application itself is a basic example using  the rocket library (<a href="https://rocket.rs/" rel="noreferrer">https://rocket.rs/</a>) it looks like this </p>
  
  <pre><code>#![feature(proc_macro_hygiene, decl_macro)]
  
  #[macro_use] extern crate rocket;
  
  #[get("/")]
  fn index() -&gt; &amp;'static str {
      "Hello, world!"
  }
  
  fn main() {
      rocket::ignite().mount("/", routes![index]).launch();
  }
  </code></pre>
  
  <p>I have compiled this and called it <code>server</code></p>
  
  <p>I then created a Docker file to host it</p>
  
  <pre><code>FROM ubuntu:16.04
  
  RUN apt-get update; apt-get install -y curl
  
  COPY server /root/
  
  EXPOSE 8000
  
  CMD ["/root/server"]                           
  </code></pre>
  
  <p>I build the docker image with 
  <code>$ docker build -t port_test</code> and run it with <code>$ docker run -p 8000:8000 port_test</code></p>
  
  <p>At this point it all looks good </p>
  
  <pre><code>$ docker ps
  CONTAINER ID        IMAGE               COMMAND             CREATED                     STATUS              PORTS                    NAMES
  3befe0c272f7        port_test           "/root/server"      7 minutes ago       Up 7 minutes        0.0.0.0:8000-&gt;8000/tcp   festive_wilson
  </code></pre>
  
  <p>If I run curl within the container it works fine </p>
  
  <pre><code>$ docker exec -it 3befe0c272f7 curl -s localhost:8000
  Hello, world!
  </code></pre>
  
  <p>However I can't do the same from the host</p>
  
  <pre><code>$ curl localhost:8000
  curl: (56) Recv failure: Connection reset by peer
  </code></pre>