Reputation: 1285
I'm new to docker-compose
and go
so be kind. I've looked at similar questions to this on SO, but they're either 1) for different versions of Go or 2) for Linux. I'm on Windows 10. Go version is 1.19
I'm trying to follow along with a course which is out of date of course, and they're using a Mac, so that might be another reason why this isn't working, but I have a project structure and files that look like this (highlighted areas of interest):
When I try to run the command docker-compose up
like it says in the course, I get the error. What's causing it and how do I fix it (as a newbie asking)?
Upvotes: 2
Views: 2393
Reputation: 1189
You could try something like this where you build first and then try to run the binary. here is the docker documentation on it
and in case the link breaks:
FROM golang:1.16-alpine
WORKDIR /app
COPY go.mod ./
COPY go.sum ./
RUN go mod download
COPY . ./
RUN go build -o /<your binary name>
EXPOSE 8080
CMD [ "/<same binary name>" ]
Upvotes: 2