Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when handling FROM, buildx should check local image store first? #199

Closed
jingxiaolu opened this issue Dec 4, 2019 · 5 comments · Fixed by #200
Closed

when handling FROM, buildx should check local image store first? #199

jingxiaolu opened this issue Dec 4, 2019 · 5 comments · Fixed by #200

Comments

@jingxiaolu
Copy link
Contributor

Env:

docker 19.03.5 + buildx, no connection to dockerhub

buildx version: github.com/docker/buildx v0.3.1-13-g8bce430.m 8bce430f4d74c9a9ca72a46139804e88502d4b78.m

What I'm trying to do

Build a simple image with Dockerfile:

FROM xxx_gcc:aarch64
RUN gcc "-DARCH=\"`uname -a`\"" hello.c -o hello
ENTRYPOINT ["/hello"]

Problem I met

I have loaded the image xxx_gcc:aarch64 to dockerd, so this Dockerfile works fine with docker build .

But when I try docker buildx build ., it fails with:

# docker buildx build --pull  .
WARN[0000] No output specified for docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
[+] Building 40.1s (4/5)
 => [internal] load build definition from Dockerfile                                                                                                                                                         0.1s
 => => transferring dockerfile: 92B                                                                                                                                                                          0.0s
 => [internal] load .dockerignore                                                                                                                                                                            0.1s
 => => transferring context: 2B                                                                                                                                                                              0.0s
 => ERROR [internal] load metadata for xxx_gcc:aarch64                                                                                                            20.0s
 => ERROR [1/2] FROM xxx_gcc:aarch64                                                                                                                              20.0s
 => => resolve xxx_gcc:aarch64                                                                                                                                    20.0s
------
 > [internal] load metadata for xxx_gcc:aarch64:
------
------
 > [1/2] FROM xxx_gcc:aarch64:
------
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to build LLB: failed to load cache key: failed to do request: Head [REDACTED]/xxx_gcc/manifests/aarch64: dial tcp: lookup [REDACTED]: read udp [REDACTED]: i/o timeout

What I expect

When docker build, it will first check whether the image in FROM exists in local store, but docker buildx build always trying to pull it from remote registry.

For this case, from my POV, buildx should only pull the image from remote registry when --pull is specified:

--pull                     Always attempt to pull a newer version of the image

Please help to check, thanks!

@tonistiigi
Copy link
Member

To use images from docker image store you need to use the docker driver. From the logs, you are using the container driver that does not have access to your docker images.

@jingxiaolu
Copy link
Contributor Author

thanks @tonistiigi , after switched to docker driver, it's OK now~

One similar question on docker buildx inspect mybuilder --bootstrap, mybuild is docker-container driver.
When inspecting with --bootstrap, it will pull & run image moby/buildkit:buildx-stable-1.
It will pull image first, but not check local docker image store whether this image exists, so it always fail in my env:

# docker buildx inspect mybuilder --bootstrap
[+] Building 0.0s (1/1) FINISHED
 => ERROR [internal] booting buildkit                                                                                                                                                                        0.0s
 => => pulling image moby/buildkit:buildx-stable-1                                                                                                                                                           0.0s
------
 > [internal] booting buildkit:
------
Name:   mybuilder
Driver: docker-container

Nodes:
Name:      mybuilder0
Endpoint:  unix:///var/run/docker.sock
Status:    inactive
Platforms:

The related code is

rc, err := d.DockerAPI.ImageCreate(ctx, imageName, types.ImageCreateOptions{})

I think before ImageCreate(), we can call ImageInspectWithRaw() to check docker image store?

@tonistiigi
Copy link
Member

@jingxiaolu Sure, we should probably still try to pull first, but if it fails we could check if image with that name already exists and not error if it does.

@jingxiaolu
Copy link
Contributor Author

@tonistiigi thanks for your clarification!
So I can make a PR with ImageInspectWithRaw() when ImageCreate() returns error for docker buildx inspect mybuilder --bootstrap?

@tonistiigi
Copy link
Member

@jingxiaolu yes

jingxiaolu added a commit to jingxiaolu/buildx that referenced this issue Dec 6, 2019
When booting `docker-container` driver, it will pull and run image
`moby/buildkit:buildx-stable-1`.
If current node cannot connect to dockerhub, driver `docker-container`
will always booting failure.
But user may already load the image manually or pull it from a priviate
registry.
Buildx should check local docker image store after pull failed.

Fixes: docker#199 issuecomment-561996661

Signed-off-by: Lu Jingxiao <lujingxiao@huawei.com>
jingxiaolu added a commit to jingxiaolu/buildx that referenced this issue Dec 9, 2019
When booting `docker-container` driver, it will pull and run image
`moby/buildkit:buildx-stable-1`.
If current node cannot connect to dockerhub, driver `docker-container`
will always booting failure.
But user may already load the image manually or pull it from a priviate
registry.
Buildx should check local docker image store after pull failed.

Fixes: docker#199 issuecomment-561996661

Signed-off-by: Lu Jingxiao <lujingxiao@huawei.com>
jingxiaolu added a commit to jingxiaolu/buildx that referenced this issue Dec 9, 2019
When booting `docker-container` driver, it will pull and run image
`moby/buildkit:buildx-stable-1`.
If current node cannot connect to dockerhub, driver `docker-container`
will always booting failure.
But user may already load the image manually or pull it from a priviate
registry.
Buildx should check local docker image store after pull failed.

Fixes: docker#199 issuecomment-561996661

Signed-off-by: Lu Jingxiao <lujingxiao@huawei.com>
ulyssessouza pushed a commit to ulyssessouza/buildx that referenced this issue Dec 10, 2019
When booting `docker-container` driver, it will pull and run image
`moby/buildkit:buildx-stable-1`.
If current node cannot connect to dockerhub, driver `docker-container`
will always booting failure.
But user may already load the image manually or pull it from a priviate
registry.
Buildx should check local docker image store after pull failed.

Fixes: docker#199 issuecomment-561996661

Signed-off-by: Lu Jingxiao <lujingxiao@huawei.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants