rancher-sandbox / rancher-desktop

Container Management and Kubernetes on the Desktop
https://rancherdesktop.io
Apache License 2.0
5.93k stars 280 forks source link

`DOCKER_CONFIG` environment variable is not respected. #2316

Open mook-as opened 2 years ago

mook-as commented 2 years ago

Actual Behavior

Setting DOCKER_CONFIG does not change where we find ~/.docker/config.json etc.

Steps to Reproduce

Result

Expected Behavior

Only ${DOCKER_CONFIG}/… is used.

Additional Information

It's respected in the CLI here: https://github.com/docker/cli/blob/d86fce7b05137ec3857045c7fa3944dfc23f0a2e/cli/config/config.go#L52-L60

Rancher Desktop Version

2c985a0 (Just before 1.4.0)

Rancher Desktop K8s Version

N/A

Which container runtime are you using?

moby (docker cli)

What operating system are you using?

macOS

Operating System / Build Version

macOS Catalina 10.15.7

What CPU architecture are you using?

x64

Linux only: what package format did you use to install Rancher Desktop?

No response

Windows User Only

No response

jandubois commented 2 years ago

It is not clear to me if we should use environment variables, or should provide entries in our Settings/Preferences dialog for this.

For example the same issue is probably true for KUBECONFIG as well, but that variable can contain a list of config files separated by : (or ';' on Windows), so it isn't clear which file should be updated with the RD kube config. I can see an argument for always modifying the first file in the list, as that is also what is being modified by kubectl commands making changes.

Using environment variables has the advantage that they should be automatically in sync with the user's shell environment, but on the other hand, they are opaque to the UI.

Finally, at least on macOS, the environment is not accessible from the GUI app; so we would need to determine the user's default shell, instantiate a login shell, and then extract the environment settings from there.

mook-as commented 2 years ago

Oh I mainly wanted this for testing, and as a bonus may (or may not) work for some users (e.g. if you start macOS/Contents/rancher-desktop or something). But mainly for the tests :D

ericpromislow commented 1 year ago

Also docker-credential-none needs to respect DOCKER_CONFIG

And then the e2e credentials-server tests should respect it as well, and not bother restoring changed config files in their afterAll blocks.

src/utils/dockerDirManager.ts will also need to be changed.