I am working on a tutorial for Docker, and I am learning about docker build. In the tutorial, this is the docker file
FROM ubuntu:14.04
RUN apt-get update -y
RUN apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_4.x | bash -
RUN apt-get install -y node.js
COPY server.js /
EXPOSE 8080
CMD [ "node", "/server.js"]
In the same directory as the dockerfile is a server.js file:
// Load the http module to create an http server.
var http = require('http');
// Configure our HTTP server to respond with Hello World to all requests
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "Text/plain"});
response.end("Hello world!");
})
// Listen on port 8080
server.listen(8080, function() {
console.log('Server listening...');
})
From command line I run docker build: docker build -t ahawkins/docker-into-hello-world .
Then I run the container from the above image: docker run -d -p 8080:8080 ahawkins/docker-intro-hello-world
I expect a curl localhost:8080
to respond with "Hello world!"
, but instead I get:
curl: (52) Empty reply from server
I ssh into the container and see that server.js
is no where to be found, and moreover I cannot even find the node installation.
Have I installed node correctly? Should I expect to see a server.js
file at the root of the operating system? Why am I not seeing a, "Hello World!", from my curl command?