docker / buildx

Docker CLI plugin for extended build capabilities with BuildKit
Apache License 2.0
3.54k stars 480 forks source link

stuck at pushing image to docker hub #129

Closed krasi-georgiev closed 5 years ago

krasi-georgiev commented 5 years ago

I created a build context to use my local machine amd64 and a remote Rpi arm/v7

docker buildx ls
NAME/NODE DRIVER/ENDPOINT             STATUS  PLATFORMS
multi *   docker-container                    
  multi0  unix:///var/run/docker.sock running linux/amd64
  multi1  ssh://root@loraserver.local running linux/arm/v7, linux/arm/v6
default   docker                              
  default default                     running linux/amd64

The build process seems to gets stuck at pushing the image.

docker buildx build --platform linux/amd64,linux/arm/v7 -t arribada/gateway --push --progress=plain  .

It is a simple golang app

FROM --platform=$BUILDPLATFORM golang:alpine AS build
RUN apk add --no-cache git
COPY ./ /tmp/builder/
WORKDIR /tmp/builder/
RUN CGO_ENABLED=0 go build  -o main .
FROM alpine
COPY --from=build main /usr/local/bin/
CMD /usr/local/bin/main
docker buildx build --platform linux/amd64,linux/arm/v7 -t arribada/gateway --push --progress=plain --no-cache .
#1 [internal] booting buildkit
#1 starting container buildx_buildkit_multi1
#1 starting container buildx_buildkit_multi1 8.2s done
#1 DONE 8.2s

#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.1s

#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 32B done
#2 DONE 0.1s

#5 [linux/amd64 internal] load metadata for docker.io/library/golang:alpine
#5 DONE 1.9s

#4 [linux/amd64 internal] load metadata for docker.io/library/alpine:latest
#4 DONE 2.0s

#7 [linux/amd64 build 1/5] FROM docker.io/library/golang:alpine@sha256:87e5...
#7 resolve docker.io/library/golang:alpine@sha256:87e527712342efdb8ec5ddf2d57e87de7bd4d2fedf9f6f3547ee5768bb3c43ff done
#7 CACHED

#6 [linux/amd64 stage-1 1/2] FROM docker.io/library/alpine@sha256:6a92cd1fc...
#6 resolve docker.io/library/alpine@sha256:6a92cd1fcdc8d8cdec60f33dda4db2cb1fcdcacf3410a8e05b3741f44a9b5998 done
#6 CACHED

#9 [internal] load build context
#9 transferring context: 119B done
#9 DONE 0.1s

#8 [linux/amd64 build 2/5] RUN apk add --no-cache git
#8 0.272 fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
#8 0.662 fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
#8 0.890 (1/5) Installing nghttp2-libs (1.38.0-r0)
#8 0.939 (2/5) Installing libcurl (7.65.1-r0)
#8 0.998 (3/5) Installing expat (2.2.7-r0)
#8 1.044 (4/5) Installing pcre2 (10.33-r0)
#8 1.107 (5/5) Installing git (2.22.0-r0)
#8 1.753 Executing busybox-1.30.1-r2.trigger
#8 1.758 OK: 21 MiB in 20 packages
#8 DONE 1.9s

#10 [linux/amd64 build 3/5] COPY ./ /tmp/builder/
#10 DONE 0.1s

#11 [linux/amd64 build 4/5] WORKDIR /tmp/builder/
#11 DONE 0.1s

#12 [linux/amd64 build 5/5] RUN CGO_ENABLED=0 go build  -o main .
#12 0.323 go: finding github.com/pkg/errors v0.8.1
#12 0.324 go: finding github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
#12 0.324 go: finding github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4
#12 0.324 go: finding github.com/brocaar/lorawan v0.0.0-20190725071148-7d77cf375455
#12 0.325 go: finding github.com/twpayne/go-geom v1.0.6-0.20190712172859-6e5079ee5888
#12 1.187 go: finding gopkg.in/alecthomas/kingpin.v2 v2.2.6
#12 2.522 go: finding github.com/sirupsen/logrus v1.3.0
#12 2.524 go: finding github.com/stretchr/testify v1.3.0
#12 2.525 go: finding github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3
#12 2.526 go: finding github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a
#12 2.527 go: finding github.com/jacobsa/oglemock v0.0.0-20150831005832-e94d794d06ff
#12 2.528 go: finding github.com/jacobsa/crypto v0.0.0-20180924003735-d95898ceee07
#12 2.529 go: finding github.com/NickBall/go-aes-key-wrap v0.0.0-20170929221519-1c3aa3e4dfc5
#12 2.620 go: finding github.com/opencontainers/runc v0.1.1
#12 2.789 go: finding golang.org/x/net v0.0.0-20190328230028-74de082e2cca
#12 3.499 go: finding github.com/ory/dockertest v3.3.4+incompatible
#12 4.391 go: finding github.com/DATA-DOG/go-sqlmock v1.3.2
#12 4.636 go: finding github.com/opencontainers/go-digest v1.0.0-rc1
#12 4.738 go: finding github.com/d4l3k/messagediff v1.2.1
#12 4.919 go: finding github.com/opencontainers/image-spec v1.0.1
#12 5.108 go: finding golang.org/x/crypto v0.0.0-20180904163835-0709b304e793
#12 5.381 go: finding github.com/davecgh/go-spew v1.1.0
#12 6.047 go: finding github.com/lib/pq v1.0.0
#12 6.544 go: finding github.com/twpayne/go-kml v1.0.0
#12 6.596 go: finding github.com/jacobsa/ogletest v0.0.0-20170503003838-80d50a735a11
#12 6.774 go: finding github.com/docker/go-connections v0.4.0
#12 6.778 go: finding github.com/jacobsa/oglematchers v0.0.0-20150720000706-141901ea67cd
#12 7.481 go: finding github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5
#12 7.650 go: finding github.com/pmezard/go-difflib v1.0.0
#12 8.153 go: finding github.com/stretchr/objx v0.1.1
#12 8.449 go: finding golang.org/x/tools v0.0.0-20190328211700-ab21143f2384
#12 8.470 go: finding github.com/jacobsa/reqtrace v0.0.0-20150505043853-245c9e0234cb
#12 8.485 go: finding github.com/stretchr/testify v1.2.2
#12 8.614 go: finding github.com/jtolds/gls v4.20.0+incompatible
#12 8.906 go: finding github.com/twpayne/go-polyline v1.0.0
#12 8.909 go: finding github.com/gopherjs/gopherjs v0.0.0-20190328170749-bb2674552d8f
#12 8.988 go: finding golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c
#12 9.007 go: finding golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
#12 9.034 go: finding github.com/davecgh/go-spew v1.1.1
#12 9.305 go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
#12 9.523 go: finding golang.org/x/sys v0.0.0-20190402054613-e4093980e83e
#12 9.534 go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
#12 10.02 go: finding github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1
#12 10.37 go: finding github.com/containerd/continuity v0.0.0-20181203112020-004b46473808
#12 10.38 go: finding github.com/sirupsen/logrus v1.4.1
#12 10.60 go: finding github.com/stretchr/objx v0.1.0
#12 10.60 go: finding github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d
#12 10.96 go: finding github.com/cenkalti/backoff v2.1.1+incompatible
#12 12.38 go: finding github.com/docker/go-units v0.3.3
#12 12.55 go: finding golang.org/x/text v0.3.0
#12 12.83 go: finding golang.org/x/sys v0.0.0-20190405154228-4b34438f7a67
#12 13.51 go: finding golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33
#12 13.52 go: finding golang.org/x/net v0.0.0-20190311183353-d8887717615a
#12 13.52 go: finding github.com/konsorten/go-windows-terminal-sequences v1.0.1
#12 18.22 go: downloading github.com/twpayne/go-geom v1.0.6-0.20190712172859-6e5079ee5888
#12 18.22 go: downloading github.com/brocaar/lorawan v0.0.0-20190725071148-7d77cf375455
#12 18.22 go: downloading github.com/pkg/errors v0.8.1
#12 18.25 go: downloading gopkg.in/alecthomas/kingpin.v2 v2.2.6
#12 18.30 go: extracting github.com/pkg/errors v0.8.1
#12 18.36 go: extracting gopkg.in/alecthomas/kingpin.v2 v2.2.6
#12 18.37 go: downloading github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4
#12 18.37 go: downloading github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
#12 18.39 go: extracting github.com/brocaar/lorawan v0.0.0-20190725071148-7d77cf375455
#12 18.39 go: extracting github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4
#12 18.40 go: downloading github.com/jacobsa/crypto v0.0.0-20180924003735-d95898ceee07
#12 18.42 go: extracting github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
#12 18.44 go: extracting github.com/twpayne/go-geom v1.0.6-0.20190712172859-6e5079ee5888
#12 18.89 go: extracting github.com/jacobsa/crypto v0.0.0-20180924003735-d95898ceee07
#12 DONE 22.0s

#13 [linux/amd64 stage-1 2/2] COPY --from=build main /usr/local/bin/
#13 DONE 0.1s

#14 exporting to image
#14 exporting layers
#14 exporting layers 0.9s done
#14 exporting manifest sha256:b1df6565ea0301148310cbcba589664316e6467da060d44ebc83035f23ee976c 0.0s done
#14 exporting config sha256:edf051c77aa488f30f30a7891394af6d3a3a0459f87562f397b10c54b8ad5b96 0.0s done
#14 exporting manifest list sha256:5e95279884f4819a5bea408ef9b577b056c7d4aba397024052a664c2ffa1ca03 0.0s done
#14 pushing layers
#14 pushing layers 8.0s done
#14 pushing manifest for docker.io/arribada/gateway
#14 pushing manifest for docker.io/arribada/gateway 1.0s done
#14 DONE 10.0s
krasi-georgiev commented 5 years ago

not sure if it will help but when I cancel - CTRK + C it returns with: failed to receive status: rpc error: code = Canceled desc = context canceled

tonistiigi commented 5 years ago

it's hard to see from the logs when it actually get stuck. I also don't see any logs for linux/arm/v7 at all in that output. Are you saying the build works fine with just --platform linux/arm/v7 but doesn't start for arm if you specify amd64 as well?

krasi-georgiev commented 5 years ago

I just tried it with only:

docker buildx build --platform linux/arm/v7 -t arribada/gateway --push --progress=plain  .

and it doesn't start at all. No logs output

can I enable some debug logs?

krasi-georgiev commented 5 years ago

I just tried to delete and recreate this context and the buildx ls command doesn't even see it as running

$ docker buildx rm

$ docker buildx ls
NAME/NODE DRIVER/ENDPOINT STATUS  PLATFORMS
default * docker                  
  default default         running linux/amd64

$ docker buildx create --append   --name multi ssh://root@loraserver.local
WARN[0000] failed to find "multi" for append, creating a new instance instead 
multi

$ docker buildx ls
NAME/NODE DRIVER/ENDPOINT             STATUS   PLATFORMS
multi *   docker-container                     
  multi0  ssh://root@loraserver.local inactive 
default   docker                               
  default default                     running  linux/amd64

$ docker buildx inspect multi --bootstrap
[+] Building 4.5s (1/1) FINISHED                                                                                                                   
WARN[0005] commandConn.CloseWrite: commandconn: failed to wait: signal: killed                                                                4.5s
 => ERROR [internal] booting buildkit                                                                                                         4.5s
 => => pulling image moby/buildkit:master                                                                                                     4.5s
------
 > [internal] booting buildkit:
------
Name:   multi
Driver: docker-container

Nodes:
Name:      multi0
Endpoint:  ssh://root@loraserver.local
Status:    inactive
Platforms: 

$ docker buildx ls
NAME/NODE DRIVER/ENDPOINT             STATUS   PLATFORMS
multi *   docker-container                     
  multi0  ssh://root@loraserver.local inactive 
default   docker                               
  default default                     running  linux/amd64
tonistiigi commented 5 years ago

Are you sure that endpoint is repsonsive? DOCKER_HOST=ssh://root@loraserver.local docker ps and look for a container in that list after --bootstrap reports it running.

krasi-georgiev commented 5 years ago

Yes it is responsive

I think I found some usefull logs by ssh-ing in the rpi and looking at the logs of the only container there:

docker ps -a
CONTAINER ID        IMAGE                  COMMAND             CREATED             STATUS                      PORTS               NAMES
de76d9247c21        moby/buildkit:master   "buildkitd"         24 seconds ago      Exited (2) 11 seconds ago                       buildx_buildkit_multi0
root@loraserver:~# docker logs de76d9247c21
time="2019-08-05T23:55:41Z" level=warning msg="using host network as the default"
time="2019-08-05T23:55:41Z" level=info msg="found worker \"vje74b849h7h4t08bfef44tf3\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:de76d9247c21 org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/arm/v7 linux/arm/v6]"
time="2019-08-05T23:55:41Z" level=warning msg="skipping containerd worker, as \"/run/containerd/containerd.sock\" does not exist"
time="2019-08-05T23:55:41Z" level=info msg="found 1 workers, default=\"vje74b849h7h4t08bfef44tf3\""
time="2019-08-05T23:55:41Z" level=warning msg="currently, only the default worker can be used."
time="2019-08-05T23:55:41Z" level=info msg="running server on /run/buildkit/buildkitd.sock"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x4 pc=0x126f0]

goroutine 49 [running]:
github.com/moby/buildkit/control.(*Controller).Solve(0x31daf00, 0xc08e70, 0x3372f60, 0x336e510, 0x0, 0x0, 0x0)
        /src/control/control.go:217 +0x54
github.com/moby/buildkit/api/services/control._Control_Solve_Handler.func1(0xc08e70, 0x3372f60, 0xa73ac0, 0x336e510, 0xa60f78, 0x1318378, 0xc08e70, 0x3372f60)
        /src/api/services/control/control.pb.go:1364 +0x68
github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1(0xc08e10, 0x3372ee0, 0xa73ac0, 0x336e510, 0x327b4b0, 0x327b4c0, 0x0, 0x0, 0xbfbb90, 0x307c8b0)
        /src/vendor/github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc/server.go:57 +0x250
main.unaryInterceptor.func1(0xc08e10, 0x3372ee0, 0xa73ac0, 0x336e510, 0x327b4b0, 0x327b4c0, 0x0, 0x0, 0x0, 0x0)
        /src/cmd/buildkitd/main.go:526 +0xfc
github.com/moby/buildkit/api/services/control._Control_Solve_Handler(0xa3d100, 0x31daf00, 0xc08e70, 0x3372e80, 0x33a82d0, 0x327ad90, 0xc08e70, 0x3372e80, 0x319a480, 0xb7)
        /src/api/services/control/control.pb.go:1366 +0x118
google.golang.org/grpc.(*Server).processUnaryRPC(0x3100c00, 0xc10d48, 0x31281e0, 0x336e3f0, 0x33724a0, 0x12ff784, 0x0, 0x0, 0x0)
        /src/vendor/google.golang.org/grpc/server.go:972 +0x484
google.golang.org/grpc.(*Server).handleStream(0x3100c00, 0xc10d48, 0x31281e0, 0x336e3f0, 0x0)
        /src/vendor/google.golang.org/grpc/server.go:1252 +0xb18
google.golang.org/grpc.(*Server).serveStreams.func1.1(0x3028020, 0x3100c00, 0xc10d48, 0x31281e0, 0x336e3f0)
        /src/vendor/google.golang.org/grpc/server.go:691 +0x7c
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /src/vendor/google.golang.org/grpc/server.go:689 +0x7c
tonistiigi commented 5 years ago

Hmm, this looks like https://github.com/moby/buildkit/pull/1082

~Can you post DOCKER_HOST=ssh://root@loraserver.local docker inspect moby/buildkit:master | egrep "Id|Created"~

Same issue but a different struct. I'll submit a patch.

krasi-georgiev commented 5 years ago

thanks, let me know when you push the new image to moby/buildkit and I will test again.

krasi-georgiev commented 5 years ago

ok I see the change has been merged. When would the new master image be pushed?

tonistiigi commented 5 years ago

@krasi-georgiev The master build is automatic and the new image should have the fix

FernandoMiguel commented 5 years ago

@tonistiigi the builders have been broken since the 27th of last month sadly

krasi-georgiev commented 5 years ago

unfortunately I just tried it and still panics:

I deleted the image to make sure it pulls the last one, but not sure if it really is the last one as it shows that it was created 35h ago

docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
moby/buildkit       master              5a72ed64a203        35 hours ago        68.1MB
# docker ps -a
CONTAINER ID        IMAGE                  COMMAND             CREATED             STATUS              PORTS               NAMES
9f8d9e697672        moby/buildkit:master   "buildkitd"         13 seconds ago      Created                                 buildx_buildkit_multi0

# docker logs -f 9f8d9e697672
time="2019-08-07T09:58:07Z" level=warning msg="using host network as the default"
time="2019-08-07T09:58:09Z" level=info msg="found worker \"emlwaf149boyp27ixuf1oxca0\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:9f8d9e697672 org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/arm/v7 linux/arm/v6]"
time="2019-08-07T09:58:09Z" level=warning msg="skipping containerd worker, as \"/run/containerd/containerd.sock\" does not exist"
time="2019-08-07T09:58:09Z" level=info msg="found 1 workers, default=\"emlwaf149boyp27ixuf1oxca0\""
time="2019-08-07T09:58:09Z" level=warning msg="currently, only the default worker can be used."
time="2019-08-07T09:58:09Z" level=info msg="running server on /run/buildkit/buildkitd.sock"

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x4 pc=0x126f0]

goroutine 20 [running]:
github.com/moby/buildkit/control.(*Controller).Solve(0x35eaf00, 0xc08e70, 0x34d9060, 0x37ca360, 0x0, 0x0, 0x0)
        /src/control/control.go:217 +0x54
github.com/moby/buildkit/api/services/control._Control_Solve_Handler.func1(0xc08e70, 0x34d9060, 0xa73ac0, 0x37ca360, 0xa60f78, 0x1318378, 0xc08e70, 0x34d9060)
        /src/api/services/control/control.pb.go:1364 +0x68
github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1(0xc08e10, 0x34d8fe0, 0xa73ac0, 0x37ca360, 0x34da370, 0x34da380, 0x0, 0x0, 0xbfbb90, 0x340e868)
        /src/vendor/github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc/server.go:57 +0x250
main.unaryInterceptor.func1(0xc08e10, 0x34d8fe0, 0xa73ac0, 0x37ca360, 0x34da370, 0x34da380, 0x0, 0x0, 0x0, 0x0)
        /src/cmd/buildkitd/main.go:526 +0xfc
github.com/moby/buildkit/api/services/control._Control_Solve_Handler(0xa3d100, 0x35eaf00, 0xc08e70, 0x34d8f80, 0x34d6870, 0x3684d90, 0xc08e70, 0x34d8f80, 0x37fe180, 0xb7)
        /src/api/services/control/control.pb.go:1366 +0x118
google.golang.org/grpc.(*Server).processUnaryRPC(0x350ac00, 0xc10d48, 0x37fc000, 0x37ca1b0, 0x3774320, 0x12ff784, 0x0, 0x0, 0x0)
        /src/vendor/google.golang.org/grpc/server.go:972 +0x484
google.golang.org/grpc.(*Server).handleStream(0x350ac00, 0xc10d48, 0x37fc000, 0x37ca1b0, 0x0)
        /src/vendor/google.golang.org/grpc/server.go:1252 +0xb18
google.golang.org/grpc.(*Server).serveStreams.func1.1(0x37b0060, 0x350ac00, 0xc10d48, 0x37fc000, 0x37ca1b0)
        /src/vendor/google.golang.org/grpc/server.go:691 +0x7c
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /src/vendor/google.golang.org/grpc/server.go:689 +0x7c
krasi-georgiev commented 5 years ago

@tonistiigi if you give me your pub key or let me know where to ping you on irc I will give you access to the RPI so It would be easier to find the culprit.

tonistiigi commented 5 years ago

@krasi-georgiev https://github.com/tonistiigi.keys

tonistiigi commented 5 years ago

@krasi-georgiev Seems lot of builds failed because of connection issues for github and this patch wasn't in the build you seem to be using(based on that timestamp). I restarted it and will let you know.

tonistiigi commented 5 years ago

@krasi-georgiev The build is complete now and everything seemed to be working in your server.

krasi-georgiev commented 5 years ago

Magic! thanks a lot!

DmitryMaksakov commented 4 years ago

I have the same problem: buildx is stucking at pushing layers. On ctrl-c I have failed to solve: rpc error: code = Canceled desc = context canceled. The problem occurs only if linux/arm/v7 in the list.

sredni commented 4 years ago

Just faced the same problem, how did you fixed it?

UPDATE Ok, I found that I have one quite big layer and it simply takes time to push (235.3s). Unfortunately push doesn’t report layer progress :(