I am on a mac (El Capitan, stable, 10.11.6
) with Docker Desktop for Mac stable installed.
I am running a simple javascript app on the official node image. Here's what the Dockerfile
looks like:
FROM node
WORKDIR /usr/local/src
And here's the docker-compose.yml
:
version: '2'
services:
web:
container_name: myproject_dev
build: .
command: npm run development
ports:
- "1234:8000"
- "1235:8080"
- "80:80"
volumes:
- ./my-project:/usr/local/src
Running docker-compose up
starts everything normally:
myproject_dev | http://localhost:8080/webpack-dev-server/
myproject_dev | webpack result is served from /assets/
myproject_dev | content is served from /usr/local/src
And docker ps
shows that the ports are mapped:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
820694f618b4 myproject_web "npm run development" 20 minutes ago Up 20 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:1234->8000/tcp, 0.0.0.0:1235->8080/tcp myproject_dev
But I am unable to see the project page on the browser (using localhost:1234
). Works fine when I run the project outside the docker. So, an issue with the project is ruled out.
Tried the following:
node
dockerBut no luck :( What am I missing here?
The service you're running is only listening to the containerlocalhost
interface, so nothing outside the container can access it. It needs to listen on 0.0.0.0
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With