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:
docker build -t oror/rust-testdocker run -it -p 8080:8080 --rm -v $(pwd):/source -w /source oror/rust-test cargo rundocker ps
ifconfigto get my machine's IP address:192.168.0.6curl 192.168.0.6:8080to 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?