moby / moby/buildkit

Error during build using corporate proxy

Open
#4,725 21 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area/windows area/windows-lcow status/needs-investigation
Dominant language
Go
Stars
10.3k
Forks
1.5k
Avg merge
1d 23h
Merged PRs (30d)
48

Description

We are using corporate proxy and all our outside traffic goes only through a proxy. I can't connect to internet without a proxy.

I'm trying to build new image based on another image.

Dockerfile looks like:

FROM nginx:1.13-alpine
COPY conf /etc/nginx/conf.d/default.conf

The error message:

[+] Building 30.2s (3/3) FINISHED                                                                                                                                                                                             docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                                                    0.0s
 => => transferring dockerfile: 101B                                                                                                                                                                                                    0.0s
 => ERROR [internal] load metadata for docker.io/library/nginx:1.13-alpine                                                                                                                                                             30.1s
 => [auth] library/nginx:pull token for registry-1.docker.io                                                                                                                                                                            0.0s
------
 > [internal] load metadata for docker.io/library/nginx:1.13-alpine:
------
Dockerfile:1
--------------------
   1 | >>> FROM nginx:1.13-alpine
   2 |     COPY conf /etc/nginx/conf.d/default.conf
--------------------
ERROR: failed to solve: DeadlineExceeded: DeadlineExceeded: DeadlineExceeded: nginx:1.13-alpine: failed to authorize: DeadlineExceeded: failed to fetch oauth token: Post "https://auth.docker.io/token": dial tcp 54.227.20.253:443: i/o timeout

But another Dockerfile works well:

FROM mcr.microsoft.com/dotnet/aspnet:6.0
COPY conf /etc/nginx/conf.d/default.conf

Also manually pulling image works well. A command for manually pulling:

docker pull nginx:1.13-alpine

A proxy is configured in Docker (desktop) for both http and https connections and also in windows settings.

I've tried to use debug command docker --debug build . and it returns:

Dockerfile:1
--------------------
   1 | >>> FROM nginx:1.13-alpine
   2 |     COPY conf /etc/nginx/conf.d/default.conf
--------------------
ERROR: failed to solve: DeadlineExceeded: DeadlineExceeded: DeadlineExceeded: nginx:1.13-alpine: failed to authorize: DeadlineExceeded: failed to fetch oauth token: Post "https://auth.docker.io/token": dial tcp 54.227.20.253:443: i/o timeout
23236 v0.12.1-desktop.4 C:\Program Files\Docker\cli-plugins\docker-buildx.exe --debug buildx build .
github.com/moby/buildkit/session/auth/authprovider.(*authProvider).FetchToken.func2
        github.com/moby/buildkit@v0.12.0/session/auth/authprovider/authprovider.go:100
github.com/moby/buildkit/session/auth/authprovider.(*authProvider).FetchToken
        github.com/moby/buildkit@v0.12.0/session/auth/authprovider/authprovider.go:124
github.com/moby/buildkit/session/auth._Auth_FetchToken_Handler.func1
        github.com/moby/buildkit@v0.12.0/session/auth/auth.pb.go:954
github.com/moby/buildkit/session.NewSession.ChainUnaryServer.func3.1.1
        github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/chain.go:25
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc.UnaryServerInterceptor.func1
        go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc@v0.40.0/interceptor.go:342
github.com/moby/buildkit/session.NewSession.filterServer.func1
        github.com/moby/buildkit@v0.12.0/session/session.go:177
github.com/moby/buildkit/session.NewSession.ChainUnaryServer.func3.1.1
        github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/chain.go:25
github.com/moby/buildkit/session.NewSession.ChainUnaryServer.func3
        github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0/chain.go:34
github.com/moby/buildkit/session/auth._Auth_FetchToken_Handler
        github.com/moby/buildkit@v0.12.0/session/auth/auth.pb.go:956
google.golang.org/grpc.(*Server).processUnaryRPC
        google.golang.org/grpc@v1.53.0/server.go:1336
google.golang.org/grpc.(*Server).handleStream
        google.golang.org/grpc@v1.53.0/server.go:1704
google.golang.org/grpc.(*Server).serveStreams.func1.2
        google.golang.org/grpc@v1.53.0/server.go:965
runtime.goexit
        runtime/asm_amd64.s:1650

183  /usr/local/bin/dockerd --containerd /run/containerd/containerd.sock --pidfile /run/desktop/docker.pid --swarm-default-advertise-addr=eth0 --host-gateway-ip 192.168.65.254
github.com/moby/buildkit/session.grpcClientConn.ChainUnaryClient.func6.1.1
        /root/build-deb/engine/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:72
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc.UnaryClientInterceptor.func1
        /root/build-deb/engine/vendor/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/interceptor.go:107
github.com/moby/buildkit/session.grpcClientConn.filterClient.func4
        /root/build-deb/engine/vendor/github.com/moby/buildkit/session/session.go:186
github.com/moby/buildkit/session.grpcClientConn.ChainUnaryClient.func6.1.1
        /root/build-deb/engine/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:72
github.com/moby/buildkit/session.grpcClientConn.ChainUnaryClient.func6
        /root/build-deb/engine/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:81
google.golang.org/grpc.(*ClientConn).Invoke
        /root/build-deb/engine/vendor/google.golang.org/grpc/call.go:35
github.com/moby/buildkit/session/auth.(*authClient).FetchToken
        /root/build-deb/engine/vendor/github.com/moby/buildkit/session/auth/auth.pb.go:869
github.com/moby/buildkit/session/auth.FetchToken.func1
        /root/build-deb/engine/vendor/github.com/moby/buildkit/session/auth/auth.go:59
github.com/moby/buildkit/session.(*Manager).Any
        /root/build-deb/engine/vendor/github.com/moby/buildkit/session/group.go:82
github.com/moby/buildkit/session/auth.FetchToken
        /root/build-deb/engine/vendor/github.com/moby/buildkit/session/auth/auth.go:56
github.com/moby/buildkit/util/resolver.(*authHandler).fetchToken
        /root/build-deb/engine/vendor/github.com/moby/buildkit/util/resolver/authorizer.go:341
github.com/moby/buildkit/util/resolver.(*authHandler).doBearerAuth.func1
        /root/build-deb/engine/vendor/github.com/moby/buildkit/util/resolver/authorizer.go:307
github.com/moby/buildkit/util/flightcontrol.(*call[...]).run
        /root/build-deb/engine/vendor/github.com/moby/buildkit/util/flightcontrol/flightcontrol.go:121
sync.(*Once).doSlow
        /usr/local/go/src/sync/once.go:74
sync.(*Once).Do
        /usr/local/go/src/sync/once.go:65
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1650

183  /usr/local/bin/dockerd --containerd /run/containerd/containerd.sock --pidfile /run/desktop/docker.pid --swarm-default-advertise-addr=eth0 --host-gateway-ip 192.168.65.254
github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb.toDispatchState.toDispatchState.func3.func4
        /root/build-deb/engine/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert.go:413
golang.org/x/sync/errgroup.(*Group).Go.func1
        /root/build-deb/engine/vendor/golang.org/x/sync/errgroup/errgroup.go:75
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1650

23236 v0.12.1-desktop.4 C:\Program Files\Docker\cli-plugins\docker-buildx.exe --debug buildx build .
google.golang.org/grpc.getChainUnaryInvoker.func1
        google.golang.org/grpc@v1.53.0/clientconn.go:361
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc.UnaryClientInterceptor.func1
        go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc@v0.40.0/interceptor.go:99
github.com/moby/buildkit/client.New.filterInterceptor.func6
        github.com/moby/buildkit@v0.12.0/client/client.go:403
google.golang.org/grpc.DialContext.chainUnaryClientInterceptors.func3
        google.golang.org/grpc@v1.53.0/clientconn.go:349
google.golang.org/grpc.(*ClientConn).Invoke
        google.golang.org/grpc@v1.53.0/call.go:35
github.com/moby/buildkit/frontend/gateway/pb.(*lLBBridgeClient).Solve
        github.com/moby/buildkit@v0.12.0/frontend/gateway/pb/gateway.pb.go:2875
github.com/moby/buildkit/client.(*gatewayClientForBuild).Solve
        github.com/moby/buildkit@v0.12.0/client/build.go:89
github.com/moby/buildkit/frontend/gateway/grpcclient.(*grpcClient).Solve
        github.com/moby/buildkit@v0.12.0/frontend/gateway/grpcclient/client.go:411
github.com/docker/buildx/build.BuildWithResultHandler.func3.1.2
        github.com/docker/buildx/build/build.go:950
github.com/moby/buildkit/frontend/gateway/grpcclient.(*grpcClient).Run
        github.com/moby/buildkit@v0.12.0/frontend/gateway/grpcclient/client.go:214
github.com/moby/buildkit/client.(*Client).Build.func2
        github.com/moby/buildkit@v0.12.0/client/build.go:59
github.com/moby/buildkit/client.(*Client).solve.func3
        github.com/moby/buildkit@v0.12.0/client/solve.go:283
golang.org/x/sync/errgroup.(*Group).Go.func1
        golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75
runtime.goexit
        runtime/asm_amd64.s:1650

183  /usr/local/bin/dockerd --containerd /run/containerd/containerd.sock --pidfile /run/desktop/docker.pid --swarm-default-advertise-addr=eth0 --host-gateway-ip 192.168.65.254
github.com/moby/buildkit/frontend/gateway.(*llbBridgeForwarder).Return
        /root/build-deb/engine/vendor/github.com/moby/buildkit/frontend/gateway/gateway.go:923
github.com/moby/buildkit/control/gateway.(*GatewayForwarder).Return
        /root/build-deb/engine/vendor/github.com/moby/buildkit/control/gateway/gateway.go:135
github.com/moby/buildkit/frontend/gateway/pb._LLBBridge_Return_Handler.func1
        /root/build-deb/engine/vendor/github.com/moby/buildkit/frontend/gateway/pb/gateway.pb.go:3216
github.com/docker/docker/api/server/router/grpc.NewRouter.ChainUnaryServer.func1.1.1
        /root/build-deb/engine/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:25
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc.UnaryServerInterceptor.func1
        /root/build-deb/engine/vendor/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/interceptor.go:376
github.com/docker/docker/api/server/router/grpc.unaryInterceptor.func1
        /root/build-deb/engine/api/server/router/grpc/grpc.go:58
github.com/docker/docker/api/server/router/grpc.NewRouter.ChainUnaryServer.func1.1.1
        /root/build-deb/engine/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:25
github.com/docker/docker/api/server/router/grpc.NewRouter.ChainUnaryServer.func1
        /root/build-deb/engine/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:34
github.com/moby/buildkit/frontend/gateway/pb._LLBBridge_Return_Handler
        /root/build-deb/engine/vendor/github.com/moby/buildkit/frontend/gateway/pb/gateway.pb.go:3218
google.golang.org/grpc.(*Server).processUnaryRPC
        /root/build-deb/engine/vendor/google.golang.org/grpc/server.go:1374
google.golang.org/grpc.(*Server).handleStream
        /root/build-deb/engine/vendor/google.golang.org/grpc/server.go:1751
google.golang.org/grpc.(*Server).serveStreams.func1.1
        /root/build-deb/engine/vendor/google.golang.org/grpc/server.go:986
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1650

23236 v0.12.1-desktop.4 C:\Program Files\Docker\cli-plugins\docker-buildx.exe --debug buildx build .
google.golang.org/grpc.getChainUnaryInvoker.func1
        google.golang.org/grpc@v1.53.0/clientconn.go:361
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc.UnaryClientInterceptor.func1
        go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc@v0.40.0/interceptor.go:99
github.com/moby/buildkit/client.New.filterInterceptor.func6
        github.com/moby/buildkit@v0.12.0/client/client.go:403
google.golang.org/grpc.DialContext.chainUnaryClientInterceptors.func3
        google.golang.org/grpc@v1.53.0/clientconn.go:349
google.golang.org/grpc.(*ClientConn).Invoke
        google.golang.org/grpc@v1.53.0/call.go:35
github.com/moby/buildkit/api/services/control.(*controlClient).Solve
        github.com/moby/buildkit@v0.12.0/api/services/control/control.pb.go:2208
github.com/moby/buildkit/client.(*Client).solve.func2
        github.com/moby/buildkit@v0.12.0/client/solve.go:258
golang.org/x/sync/errgroup.(*Group).Go.func1
        golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75
runtime.goexit
        runtime/asm_amd64.s:1650

23236 v0.12.1-desktop.4 C:\Program Files\Docker\cli-plugins\docker-buildx.exe --debug buildx build .
github.com/moby/buildkit/client.(*Client).solve.func2
        github.com/moby/buildkit@v0.12.0/client/solve.go:273
golang.org/x/sync/errgroup.(*Group).Go.func1
        golang.org/x/sync@v0.3.0/errgroup/errgroup.go:75
runtime.goexit
        runtime/asm_amd64.s:1650

I tried to run command RUN curl -x "<mycorporateproxy>" "some url" -k using docker build in another Dockerfile and it works. It means that corporate proxy works well.
I think that command docker build . ignores corporate proxy on Windows.

OS: Windows 10 2022 H2
Docker desktop: v4.28.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Dockerfile build with the configured corporate proxy and compare it with the working docker pull and alternate base image. Inspect the reported BuildKit paths, especially session/auth/authprovider/authprovider.go:100 and resolver/authorizer.go:341, to trace the failed token request. Done means the nginx base image can be built through the proxy without the DeadlineExceeded error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
build-system, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.