Answer the question
In order to leave comments, you need to log in
How to run a web page in Golang from under Docker?
Hello, I ran into such a problem that I can’t run a Golang website from under Docker.
I have docker-compose , I build golang in it
app:
build:
context: ./api/docker
dockerfile: golang.dockerFile
volumes:
- "./api:/go"
container_name: golang_app
ports:
- "9097:8080"
tty: true
depends_on:
- db
FROM golang:latest
RUN apt-get update
RUN go get "github.com/go-sql-driver/mysql"
RUN go get "github.com/gorilla/mux"
Answer the question
In order to leave comments, you need to log in
Judging by the code, you are listening on port 9098 on the localhost.
At the same time, you are redirecting the docker to port 8080.
ports:
- "9097:8080"
log.Fatal(http.ListenAndServe(":8080", r))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question