Docker Community Forums

Share and learn in the Docker community.

Go/React Docker gives me 404 page on localhost:3000

Hi, I am pretty new to using docker and I was trying to follow a guide online but for some reason, I am not able to get my server up and running with a go backend and react frontend. Here is my dockerfile:

# Build the Go API
FROM golang:latest AS builder
ADD . /app
WORKDIR /app/server
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-w" -a -o /main .

# Build the React application
FROM node:alpine AS node_builder
COPY --from=builder /app/client .
RUN npm install
RUN npm run build

# Final stage build, this will be the container
# that we will deploy to production
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /main .
COPY --from=node_builder /build ./web
RUN chmod +x ./main
CMD ./main

here is my filesystem structure:


when I run my docker image doing:

$ docker build -t react-go .
$ docker run -p 3000:8080 -d react-go 

But after I do all this I go to localhost:3000 and get a 404… Any Ideas???

A 404 Not Found error at least tells you that the container is running: it is not some error generated by Docker, but an error generated by a web server in your own application.

Any chance you’re supposed to open http://localhost:3000/client or http://localhost:3000/web ?

Also, which online guide are you following?