I am trying to run the docker image on Port 4000. But I am not able to run but able to run on Port 80. What I am doing here?
FROM node:latest as build
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM nginx:latest
COPY --from=build /usr/src/app/dist/admin /usr/share/nginx/html
EXPOSE 4200
And I am creating image from this command
docker build --pull --rm -f "DockerFile" -t admin1:v1 "."
And when I am running on port 80 then I am able to use
docker run --rm -d -p 4200:4200/tcp -p 80:80/tcp admin1:v1
But when I am running this command then I am not able to
docker run --rm -d -p 4200:4200/tcp -p 4000:4000/tcp admin1:v1
I have seen other questions online for the same question. But I am not able to fix my problem. Any suggestion will be of great help!
CodePudding user response:
You need to map the docker container port to the docker host port.
Try the following Command
docker run --rm -d -p 4200:4200/tcp -p 4000:80/tcp admin1:v1
The following is the extract from the Docker Documentation
-p 8080:80 Map TCP port 80 in the container to port 8080 on the Docker host.
You can refer the link for further information. Docker Documentation