Open yankeguo opened 2 months ago
@thaJeztah I can't reproduce but the error printed here("A self-sufficient runtime for containers") is coming from docker/cli
I suspect the problem is in this part;
buildx: Docker Buildx (Docker Inc.)
Version: v0.16.2-desktop.1
Path: /Users/myusername/.docker/cli-plugins/docker-buildx
CLI plugins are discovered in a number of locations; some "system-wide", and some "per user"
/usr/[local/]lib/docker/cli-plugins
/usr/[local/]libexec/docker/cli-plugins
~/.docker/cli-plugins/
The last one allows overriding the system-installed version, but I think the ~/.docker
here is not hard-coded, but "config-directory". So using --config <custom directory>
not only switches the location to look for the config-file, but also other content related to the config-directory (including those plugins, and likely contexts and state stored by plugins inside the config-directory).
Trying to mimic that situation;
docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock docker:cli
apk add -qq --no-cache js
docker info --format '{{json .ClientInfo.Plugins}}' | jq .
[
{
"SchemaVersion": "0.1.0",
"Vendor": "Docker Inc.",
"Version": "v0.17.1",
"ShortDescription": "Docker Buildx",
"Name": "buildx",
"Path": "/usr/local/libexec/docker/cli-plugins/docker-buildx"
},
{
"SchemaVersion": "0.1.0",
"Vendor": "Docker Inc.",
"Version": "v2.29.7",
"ShortDescription": "Docker Compose",
"Name": "compose",
"Path": "/usr/local/libexec/docker/cli-plugins/docker-compose"
}
]
Moving the plugins to ~/.docker/cli-plugins
;
mkdir -p ~/.docker/cli-plugins/
mv usr/local/libexec/docker/cli-plugins/* ~/.docker/cli-plugins/
Without custom config-dir;
docker build --help
Start a build
Usage: docker buildx build [OPTIONS] PATH | URL | -
Start a build
...
With a custom config-dir;
docker --config=/foo/ build --help
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
Install the buildx component to build images with BuildKit:
https://docs.docker.com/go/buildx/
Usage: docker build [OPTIONS] PATH | URL | -
This is somewhat of a known issue; there's various tickets (and backlog items) related to revamping storage locations (also in relation to rootless mode, which has some additional logic, and use of XDG directories). While it's a known issue, it's grown to be more problematic with the introduction of many plugins, and other parts of docker (ab)using ~/.docker
for a growing list of purposes (which can be particularly problematic when that involves platform-specific content, and users (e.g.) bind-mount the config-directory into a container).
It's not a trivial thing to change though, as there's many tools that implemented these paths and logic, so at least it will require a long transition period; it will also involve changes in Docker Desktop (which uses this location for various purposes as well, including cli-plugins it ships).
Let me at least transfer this ticket to the CLI repository, which has the core parts of this logic, and link it from the internal backlog item(s) related to this.
on my mac I get the following:
❯ docker --config ~/.docker/docker compose ls
docker: 'compose' is not a docker command.
See 'docker --help'
Contributing guidelines
I've found a bug and checked that ...
Description
I use different
DOCKER_CONFIG
directories to switch among different tenants of the same Container Registry.Recently, I found that when I set the
DOCKER_CONFIG
directory parameter, whether through the--config
parameter or theDOCKER_CONFIG
environment variable, thedocker buildx build
command parameter parsing will be completely messed up, reporting that--platform
,-t
and other parameters cannot be recognized.Expected behaviour
Command like
should work
Actual behaviour
An error raised:
When I omit
--config
option, everything works.Even if I set
DOCKER_CONFIG
environment variable, it will also fall.Buildx version
github.com/docker/buildx v0.16.2-desktop.1 081c21b9e461293ae243a1ff813a680a4f5f8fb9
Docker info
Builders list
Configuration
Build logs
No response
Additional info
No response