Reputation: 121
I have a Angular Project running in a docker container at port 4200. I have done a port mapping from docker container's 4200 port to my localhost 4200.
I am running this on Ubuntu 16.04. When doing netstat -nltp
, I get output
tcp6 0 0 :::4200 :::* LISTEN
My Dockerfile looks like :
FROM node
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app
RUN npm cache clean --force
RUN npm install
COPY . /usr/src/app
EXPOSE 4200
CMD ["npm","start"]
I expected when running curl :::4200, to show me the webpage sourcecode instead of the error,
curl (56) Recv failure: Connection reset by peer
Upvotes: 1
Views: 22485
Reputation: 121
Changing the following in package.json
for my angular project did the trick.
BEFORE
{
"name": "client",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
}
AFTER
{
"name": "client",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
Follow this link for further details
Upvotes: 5
Reputation: 592
Perform a port mapping when running the container for the first time as
docker run -ti --name angular angular_image:latest -p 4200:4200
This will override the EXPOSE command in the dockerfile. In real docker would have allocated a random port mapping from the container to the host machine. So, it is necessary to have a port mapping the docker cli.
Upvotes: 0