I am using:
Mac os High sierra 10.13.6
Docker Community Edition 18.06.1-ce
GoLand 2018.2.3
Go 1.11.1 (installed by brew at /usr/local/Cellar/go/1.11.1/libexec
I am following the instructions at https://blog.jetbrains.com/go/2018/04/30/debugging-containerized-go-applications/ to remotely debug go code running in a docker container from GoLand IDE.
However, the debugger doesn't stop at the source code on calling http://localhost:8080
If I use Dockerfile.1, I see this error on running the container:
Could not create config directory: user: Current not implemented on linux/amd64.
If I use Dockerfile.2, I don't see any error on running the container.
However, debugger doesn't stop at any breakpoints in the source.
---- Dockerfile.1 ----
FROM golang:1.10.1-alpine3.7 AS build-env
ENV CGO_ENABLED 0
ADD . /go/src/hello
RUN go build -gcflags "all=-N -l" -o /server hello
RUN apk add --no-cache git
RUN go get github.com/derekparker/delve/cmd/dlv
FROM alpine:3.7
EXPOSE 8080 40000
RUN apk add --no-cache libc6-compat
WORKDIR /
COPY --from=build-env /server /
COPY --from=build-env /go/bin/dlv /
CMD ["/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "exec", "/server"]
---- Dockerfile.2 ----
FROM golang:1.10.1-alpine3.7 AS build-env
ADD . /go/src/hello
RUN apk add --no-cache libc6-compat build-base
RUN go build -gcflags "all=-N -l" -o /server hello
RUN apk add --no-cache git
RUN go get github.com/derekparker/delve/cmd/dlv
FROM alpine:3.7
EXPOSE 8080 40000
RUN apk add --no-cache libc6-compat
WORKDIR /
COPY --from=build-env /server /
COPY --from=build-env /go/bin/dlv /
CMD ["/dlv", "--listen=:40000", "--headless=true", "--api-version=2", "exec", "/server"]