executing a simple go .exe in a dockerfile

  docker, go

I have the following dockerfile and everything works fine except for running the .exe

FROM golang:latest

# Set the Current Working Directory inside the container
WORKDIR $GOPATH/src/github.com/user/goserver

# Copy everything from the current directory to the PWD (Present Working Directory) inside the container
COPY . .

# Download all the dependencies
RUN go get -d -v ./...

# Install the package
RUN GOOS=linux GOARCH=amd64 go build -o goserver .

# This container exposes port 8080 to the outside world
EXPOSE 8080

# Run the executable
CMD ./goserver

The problem is that it does not execute ‘./goserver’. I need to manually go into the container and then execute it. Any idea what could be going wrong here ?

Source: Docker Questions

LEAVE A COMMENT