Переписал Dockerfile, заменив CMD на ENTRYPOINT, все заработало, запускал с помощью
docker run -p 8080:8080 image-name
Dockerfile:
FROM golang:1.17-alpine
# Install git.
# Git is required for fetching the dependencies.
RUN apk update && apk add --no-cache git && apk add --no-cach bash && apk add build-base
# Setup folder
WORKDIR /app
# Copy the source from the current directory to the working Directory inside the container
COPY go.mod ./
COPY .env .
RUN go mod download
COPY . .
# Build the Go app
RUN go build -a /app/cmd/goweb/
# Expose port 8080 to the outside world
EXPOSE 8080
# Run the executable, path to main.go file
ENTRYPOINT exec go run cmd/goweb/main.go