-
-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Consider handling non-existent ~/.docker/config.json
#2767
Comments
@stevenh you have this part of the code fresh in your mind. Do you think that the proposal of returning an empty map of credentials when the file does not exist is appropriate? At first sight, I see no harm on it |
BTW this test demonstrates the current error: t.Run("docker config file does not exist", func(t *testing.T) {
t.Setenv("DOCKER_CONFIG", "")
tmp := t.TempDir()
t.Setenv("HOME", tmp)
t.Setenv("USERPROFILE", tmp) // Windows
cfg, err := getDockerConfig()
require.Error(t, err)
require.Empty(t, cfg)
}) |
We encounter the same issue but apparently even setting the environment variable DOCKER_AUTH_CONFIG errors. The reason here is that the config file is checked even though there is already a loaded configuration. |
- allow missing config file -- replace registry cache key with a key generated by any defined config - allow no provided config
Did some digging and there was other config error handling edge cases which are all fixed by #2772 |
Testcontainers version
v0.33.0
Using the latest Testcontainers version?
Yes
Host OS
Ubuntu 24.04.1 LTS
Host arch
x86
Go version
1.22
Docker version
Client: Docker Engine - Community Version: 27.2.0 API version: 1.46 (downgraded from 1.47) Go version: go1.21.13 Git commit: 3ab4256 Built: Tue Aug 27 14:15:15 2024 OS/Arch: linux/amd64 Context: desktop-linux Server: Docker Desktop 4.33.0 (160616) Engine: Version: 27.1.1 API version: 1.46 (minimum version 1.24) Go version: go1.21.12 Git commit: cc13f95 Built: Tue Jul 23 19:57:19 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.7.19 GitCommit: 2bf793ef6dc9a18e00cb12efb64355c2c9d5eb41 runc: Version: 1.7.19 GitCommit: v1.1.13-0-g58aa920 docker-init: Version: 0.19.0 GitCommit: de40ad0
Docker info
What happened?
Similar to the Java testcontainers issue: testcontainers/testcontainers-java#4847, it could be useful to accept non-existent
~/.docker/config.json
when finding docker auth configs.Currently, when starting a container by building a
Dockerfile
usingtestcontainers.FromDockerfile
, a~/.docker/config.json
is required, even if no credentials are needed to build theDockerfile
. This is an issue in environments that don't have a~/.docker/config.json
by default, such as on AWS CodeBuild, as it causes tests to fail. For example, an output of a failed test when running without a~/.docker/config.json
:A workaround is to create an empty
~/.docker/config.json
or set theDOCKER_CONFIG
environment variable.I think this could be fixed by changing how the errors are handled in
getDockerAuthConfigs
by returning an emptymap[string]registry.AuthConfig
instead of an error if~/.docker/config.json
could not be found.Relevant log output
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: