Node.js Web Server on Alpine
139
FROM alpine RUN apk add --update nodejs WORKDIR /data COPY web.js /data/web.js EXPOSE 8088 CMD node /data/web.js
// import the HTTP module var http = require('http');
// define a web server port const PORT=8081;
// define a function to handle requests and send response function handleRequest(request, response) { response.end('Hi! This is Joe Tang from IBM. Path hit: ' + request.url); }
// create a server var server = http.createServer(handleRequest);
// start the web server server.listen(PORT, function() { console.log("Node.JS web server is listening on: http://localhost:%s", PORT); });
$ docker run -it --rm -p 8081:8081 --name nodeweb tangjoe88/nodejs-alpine
$ curl http://localhost:8081/
Content type
Image
Digest
sha256:b70f4d2f7…
Size
8 MB
Last updated
almost 11 years ago
docker pull tangjoe88/nodejs-alpine