Skip to content

[master / 22.06] docker buildx install breaks alias check #3789

@thaJeztah

Description

@thaJeztah

Description

Not sure when this broke (did not yet do a bisect), but I noticed that if the ~/.docker/config.json contains an alias for builder (which happens after running docker buildx install), the CLI is broken;

docker version
not allowed to alias with builtin "buildx" as target

Reproduce

make -f docker.Makefile binary

Without alias installed:

rm ~/.docker/config.json
./build/docker version
Client:
 Version:           22.06.0-beta.0-140-g3dad26ca2.m
 API version:       1.42
 Go version:        go1.19.1
 Git commit:        3dad26ca2
 Built:             Wed Sep 28 22:36:09 2022
 OS/Arch:           darwin/arm64
 Context:           default
...

After running docker buildx install;

./build/docker buildx install

cat ~/.docker/config.json
{
	"auths": {},
	"aliases": {
		"builder": "buildx"
	}
}

./build/docker version
not allowed to alias with builtin "buildx" as target

The error occurs in this part of the code inside processAliases();

if _, _, err := cmd.Find(strings.Split(v, " ")); err == nil {
return args, osArgs, errors.Errorf("not allowed to alias with builtin %q as target", v)
}

Because the cmd.Find("buildx")) returns a cmd. From a quick test the cmd it finds may be the "stub" command we create for plugins; when disabling the buildx plugin (renaming the file), the problem goes away;

mv /usr/local/lib/docker/cli-plugins/docker-buildx /usr/local/lib/docker/cli-plugins/docker-buildx-disabled
 
./build/docker version
Client:
 Version:           22.06.0-beta.0-140-g3dad26ca2.m
 API version:       1.42
 Go version:        go1.19.1
 Git commit:        3dad26ca2
 Built:             Wed Sep 28 22:36:09 2022
 OS/Arch:           darwin/arm64
 Context:           default
...

Expected behavior

No response

docker version

current master (built from https://github.com/docker/cli/commit/3dad26ca2d418092b8c4e01b03d0455d583bec86)

Client:
 Version:           22.06.0-beta.0-140-g3dad26ca2.m
 API version:       1.42
 Go version:        go1.19.1
 Git commit:        3dad26ca2
 Built:             Wed Sep 28 22:36:09 2022
 OS/Arch:           darwin/arm64
 Context:           default

docker info

not relevant

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions