I created a new Angular2 angular-cli application and ran it in Docker. But I can not connect it to the local host.
First, I run the application on my local machine:
ng new project && cd project && "put my Dockerfile there" && docker build -t my-ui .
I run it with the command:
docker run -p 4200:4200 my-ui
Then try my localhost:
curl localhost:4200
and get
curl: (56) Error Recv: connection reset using a peer
Then I tried switching to the running container (docker exec -ti container-id bash) and running curl localhost: 4200, and it works.
I also tried to start the container with -net = host param:
docker run --net=host -p 4200:4200 my-ui
And it works. What is the problem? I also tried to start the container in daemon mode and this did not help. Thanks.
My Dockerfile
FROM node RUN npm install -g angular-cli@v1.0.0-beta.24 && npm cache clean && rm -rf ~/.npm RUN mkdir -p /opt/client-ui/src WORKDIR /opt/client-ui COPY package.json /opt/client-ui/ COPY angular-cli.json /opt/client-ui/ COPY tslint.json /opt/client-ui/ ADD src/ /opt/client-ui/src RUN npm install RUN ng build
source share