Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection refused on react docker container

I'm new ro Docker, i'm trying to dockerize my react application - This is my Dockerfile:

FROM mhart/alpine-node:latest AS builder
WORKDIR /app
COPY . .
RUN npm install formik
RUN npm install axios
RUN yarn run build

FROM mhart/alpine-node
RUN yarn global add serve
WORKDIR /app
COPY --from=builder /app/build .
EXPOSE 8000
CMD ["serve", "-p", "80", "-s", "."]
  • i build the container successfully:
docker build -t frontend .
  • Then i run:
docker run 8000:80 frontend
  • When i try to access to the server on:
localhost:8080

I get connection refused. I don't know what i did wrong, Any help is appreciated.

like image 411
dev1 Avatar asked Oct 25 '25 05:10

dev1


1 Answers

You should port forward with parameter -p, like:

docker run -p 8000:80 frontend
like image 77
Andrzej Sydor Avatar answered Oct 27 '25 20:10

Andrzej Sydor