Home > Software design >  Dockerfile expose 80 port
Dockerfile expose 80 port

Time:06-09

I am trying to create a simple docker container with go mod and 1.18. my app runs in 8080 port but i wanna run in :80 port

Dockerfile

FROM golang:1.18

WORKDIR /usr/src/app

# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .
RUN go build -o server

CMD [ "./server" ]

so i run docker build:

docker build -t go-k8s . 

and docker run

docker run --rm -p 8080:8080 go-k8s:latest

And nothing happens :(

CodePudding user response:

As larsks says, you need to bind from the external port 80 to the internal port 8080 using the 80:8080 syntax.

Something else to consider is making sure that your app is listening on all interfaces in your development environment.

This question seems at least vaguely related to yours

  • Related