Running rust on Docker: Empty reply from server

Viewed 11905

I'd like to run a rust web app in a docker container. I'm new to both technologies so I've started out simple.

Here is main.rs:

extern crate iron; 
use iron::prelude::*; 
use iron::status; 
fn main() { 
    fn hello_world(_: &mut Request) -> IronResult<Response> {
        Ok(Response::with((status::Ok, "Hello World!"))) 
    } 
    Iron::new(hello_world).http("127.0.0.1:8080").unwrap(); 
}

Cargo.toml

[package]
name = "docker"
version = "0.1.0"

[dependencies]
iron = "*"

Dockerfile (adapted from this tutorial)

FROM jimmycuadra/rust

EXPOSE 8080
COPY Cargo.toml /source
COPY src/main.rs /source/src/
CMD cargo run

These are the commands I ran:

  1. docker build -t oror/rust-test
  2. docker run -it -p 8080:8080 --rm -v $(pwd):/source -w /source oror/rust-test cargo run
  3. docker ps

Terminal Ouput

  1. ifconfig to get my machine's IP address: 192.168.0.6
  2. curl 192.168.0.6:8080 to connect to my rust web app

curl: (52) Empty reply from server

I've tried localhost:8080 and I still get the same output. What am I missing?

1 Answers
Related