If I launch a Docker container by first creating the image and then running it (docker build --rm -t myApp + docker run -p 80:80 -P -d myApp), everything works fine.
But, when I do the same with Docker-compose and access to localhost, the browser returns me a ERR_EMPTY_RESPONSE error (not the typical: "Connection refused").
Where am I wrong?
Docker-compose.yml:
version: '2'
services:
myApp:
build: myApp
ports:
- "80:8000"
/myApp/Dockerfile:
FROM fedora-nodeJS
ADD app.js /
EXPOSE 8000
CMD node app
/myApp/app.js:
var http = require('http');
var PORT = 8000;
var ADDR = '0.0.0.0';
http.createServer(function(req, res) {
res.writeHead(301, { Location: 'http://stackoverflow.com' });
res.end();
}).listen(PORT,ADDR);
:: I know it makes no sense at all launch just one container with Docker-compose, but I had the same ERR_EMPTY_RESPONSE error when trying to launch several containers, so I ended up with this ridiculous scenario trying to understand whats failing.