-
Notifications
You must be signed in to change notification settings - Fork 617
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:
buildx/store/storeutil/storeutil.go
Lines 27 to 38 in 15bb14f
| // GetCurrentEndpoint returns the current default endpoint value | |
| func GetCurrentEndpoint(dockerCli command.Cli) (string, error) { | |
| name := dockerCli.CurrentContext() | |
| if name != "default" { | |
| return name, nil | |
| } | |
| de, err := GetDockerEndpoint(dockerCli, name) | |
| if err != nil { | |
| return "", errors.Errorf("docker endpoint for %q not found", name) | |
| } | |
| return de, nil | |
| } |
$ 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/v6Here 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.