1

i have been trying to dockerize an angular project, using Docker Desktop for windows, with linux containers, and Hyper-V.

Here is my dockerfile:

FROM node:alpine

WORKDIR /var/app

EXPOSE 4200

COPY package*.json ./
COPY proxy*.json ./

COPY . .
RUN npm install @angular/cli -g
#Custom dependencies
RUN npm config set registry http://maven.corp.com.br:8081/artifactory/api/npm/
RUN npm install

RUN npm run build:dev

ENTRYPOINT npm start

i build it and can run it just fine with:

docker build -t name .

docker run -p 4200:4200 name

The problem is, when i try to access https://localhost:4200 from my windows pc, i get ERR_CONNECTION_CLOSED.

However, if i go into the container cli, and use Links (the command line web browser https://i.stack.imgur.com/xOg5O.gif) to access the url, it works just fine, i'm just having issues trying to access it from my windows pc.

I tried using the host.docker.domain dns aswell but no success.

Any help will be greatly appreciated.

Thanks!

  • 1
    https://stackoverflow.com/questions/14043926/node-js-connect-only-works-on-localhost that is your issue :) – paltaa May 29 '20 at 16:14

2 Answers2

1

Thank you very much @paltaa , all i had to do was change from "npm start" to a custom "ng serve" with the flag --host 0.0.0.0"

1

change ENTRYPOINT npm start to

ENTRYPOINT npm start -- --host 0.0.0.0 --disable-host-check

or update package.json

"start": "ng serve --host 0.0.0.0 --disable-host-check",

satanTime
  • 12,631
  • 1
  • 25
  • 73