movsky
movsky

Reputation: 661

Docker and NodeJs - Not Available in browser

I installed an nodejs based image via docker compose and it seems that it all works fine, but I cannot access it in browser. I tried with localhost:4200, with 127.0.0.1:4200 and even with the ip I got from docker inspect I couldn't access it.

Here's the part of my docker-compose.yml

frontend:
    image: johnpapa/angular-cli
    container_name: frontend
    command: npm start
    working_dir: /usr/app
    volumes:
      - /home/USER/dev/angular-frontend/frontend-app:/usr/app
      - /usr/app/node_modules
    ports:
      - "4200:4200"

The output on docker run says ** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ ** and the container is up and running when I check with docker ps.

What do I have to do to access it in my browser?

Upvotes: 0

Views: 123

Answers (1)

whites11
whites11

Reputation: 13350

Your docker container's network is different from your host's.

You need to make your node process listen on all interfaces, by binding it to 0.0.0.0 rather than 127.0.0.1 or localhost.

Upvotes: 1

Related Questions