Dockerfile:
FROM golang:latest WORKDIR /app ADD . . RUN go env -w GOPROXY=https://goproxy.io,direct RUN go get RUN go build -o app . CMD ["/app/app"]
zzh@ZZHPC:/zdata/MyPrograms/Go/aaa$ docker build -t test:v1 . [+] Building 1.3s (3/3) FINISHED docker:default => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 126B 0.0s => ERROR [internal] load metadata for docker.io/library/golang:latest 1.3s ------ > [internal] load metadata for docker.io/library/golang:latest: ------ Dockerfile:1 -------------------- 1 | >>> FROM golang:latest 2 | WORKDIR /app 3 | ADD . . -------------------- ERROR: failed to solve: golang:latest: error getting credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH, out: ``
This is because I only installed docker in my Ubuntu and don't have docker desktop.
Deleting below line
"credsStore": "desktop",
from ~/.docker/config.json can fix this issue.
zzh@ZZHPC:/zdata/MyPrograms/Go/aaa$ docker build -t test:v1 . [+] Building 11.4s (11/11) FINISHED docker:default => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 176B 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [internal] load metadata for docker.io/library/golang:latest 2.6s => [1/6] FROM docker.io/library/golang:latest@sha256:c416ceeec1cdf037b80baef1ccb402c230ab83a9134b34c0902c542eb4539c82 0.0s => [internal] load build context 0.0s => => transferring context: 254B 0.0s => CACHED [2/6] WORKDIR /app 0.0s => [3/6] ADD . . 0.0s => [4/6] RUN go env -w GOPROXY=https://goproxy.io,direct 0.2s => [5/6] RUN go get 2.0s => [6/6] RUN go build -o app . 6.3s => exporting to image 0.3s => => exporting layers 0.3s => => writing image sha256:f42bb07f7315ebe8c1637fd56cef227ab658f4f9455b34e82104e7d1e8ae7cd0 0.0s => => naming to docker.io/library/test:v1 0.0s
标签:load,credential,executable,0.0,golang,internal,PATH,docker,latest From: https://www.cnblogs.com/zhangzhihui/p/17724810.html