docker / docker/buildx

Container builder endpoint should default to context name

Open
#1,410 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/driver/docker-container
Dominant language
Go
Stars
4.5k
Forks
682
Avg merge
2d 14h
Merged PRs (30d)
29

Description

When a docker-container builder is created without specifying an endpoint it will default to the docker endpoint meta host if default docker context is used whereas it will be the context name if docker context is not default:

https://github.com/docker/buildx/blob/15bb14fcf91138400e8e649e29091ca1a35e5445/store/storeutil/storeutil.go#L27-L38

$ docker context ls
NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT                                  KUBERNETES ENDPOINT   ORCHESTRATOR
default *           moby                Current DOCKER_HOST based configuration   unix:///var/run/docker.sock                                            swarm
$ docker buildx create --name foo
$ docker buildx ls
NAME/NODE       DRIVER/ENDPOINT             STATUS   BUILDKIT PLATFORMS
foo             docker-container                              
  foo0          unix:///var/run/docker.sock inactive          
default *       docker                                        
  default       default                     running  20.10.20 linux/arm64, linux/amd64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6
$ docker context create bar
$ docker context use bar
$ docker context ls
NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT                                  KUBERNETES ENDPOINT   ORCHESTRATOR
bar *               moby                                                          unix:///var/run/docker.sock                                            swarm
default             moby                Current DOCKER_HOST based configuration   unix:///var/run/docker.sock                                            swarm
$ docker buildx create --name foo2
$ docker buildx ls
NAME/NODE       DRIVER/ENDPOINT             STATUS   BUILDKIT PLATFORMS
foo             docker-container                              
  foo0          unix:///var/run/docker.sock inactive          
foo2            docker-container                              
  foo20         bar                         inactive          
bar             docker                                        
  bar           bar                         running  20.10.20 linux/arm64, linux/amd64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6
default *       docker                                        
  default       default                     running  20.10.20 linux/arm64, linux/amd64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6

Here the endpoint is unix:///var/run/docker.sock for foo0 node with default context. I think the endpoint should be default otherwise if server host changes, the builder will not be accessible anymore whereas having the context name will correctly resolve the updated context endpoint.

This is an issue I encounter when I want to switch and share the buildx store on WSL and Windows host because default context has an unix socket endpoint on WSL unix:///var/run/docker.sock but a named pipe on Windows npipe:////./pipe/docker_engine.

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 two context cases with docker buildx create and docker buildx ls, then inspect store/storeutil/storeutil.go around lines 27-38. Done means a docker-container builder created without an endpoint retains the context name, including for the default context, so it can resolve a changed host endpoint.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.