You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to create a Testcontainer with default Ryuk config fails to pull the Ryuk image in Podman, if credentials without URL scheme are present.
Relevant log output
=== RUN TestSuite
2024/04/16 14:05:24 github.com/testcontainers/testcontainers-go - Connected to docker:
Server Version: 4.9.0
API Version: 1.41
Operating System: fedora
Total Memory: 1949 MB
Resolved Docker Host: unix:///var/run/docker.sock
Resolved Docker Socket Path: /var/run/docker.sock
Test SessionID: bab906f8b9bac86f69ccd07d4da6fb3da04615205abbcce115a021fb855ac82a
Test ProcessID: 14d2b0a5-4c27-42c3-ac54-3945b168c492
2024/04/16 14:05:25 Failed to pull image: Error response from daemon: {"message":"unable to retrieve auth token: invalid username/password: unauthorized: incorrect username or password"}, will retry
2024/04/16 14:05:26 Failed to pull image: Error response from daemon: {"message":"unable to retrieve auth token: invalid username/password: unauthorized: incorrect username or password"}, will retry
[....]
Additional information
Prerequisites:
Podman is used as the engine
Ryuk image was not pulled before
Docker credentials are stored, for a registry that has no URL scheme
What happens when docker_auth.go tries to find registry credentials:
checks what registry to use
sets default registry by calling /info, request is successful but registry is empty "" (see related Podman issue)
tries to look up registry from image testcontainers/ryuk:0.7.0 -> no registry
falls back to empty "" default value
fetches auth config
tries to match config with registry
(remember: registry is empty "")
finds auth entry without URL scheme, like artifactory.mycompany.com
parses the URL successfully, since relative URL's are allowed by url.Parse()
keyURL.Host == reg matches, because parsing a scheme-less URL results in an empty host
random credentials are used
I think handling scheme-less URL's in the host based matching would be the correct thing to do here, and I'm happy to provide a fix if maintainers agree.
The text was updated successfully, but these errors were encountered:
p-jahn
changed the title
[Bug]: wrong credentials are used when no default registry and credential config contains URL without scheme
[Bug]: wrong credentials are used when no default registry configured and credential config contains URL without scheme
Apr 16, 2024
Hi @p-jahn thanks for opening this issue. It's unfortunate that Podman works differently here, but the workaround would be to always pass the fully qualified name of the Docker image.
If you consider you have bandwidth for it, please send the update 🙏
Hey @mdelapenya,
yes, that workaround would also be possible but pulling Ryuk would still be broken as it's image name is a constant in the internals. I guess setting hub.image.name.prefix could help but this then also requires that Ryuk is available in the prefix registry.
I would rather upgrade the host matching to not match empty/missing registry values against random hosts in .docker/config.json when the host there does not have an URI scheme. I think this is a general bug that is only more pronounced in Podman because of it default behaviour.
What do you think?
Edit:
misread the first answer, I'll provide a patch 🙏
forcing you to have all the images declared with their FQN
Testcontainers version
0.30.0
Using the latest Testcontainers version?
Yes
Host OS
macOS
Host arch
ARM
Go version
1.22
Docker version
Docker info
What happened?
Trying to create a Testcontainer with default Ryuk config fails to pull the Ryuk image in Podman, if credentials without URL scheme are present.
Relevant log output
Additional information
Prerequisites:
What happens when docker_auth.go tries to find registry credentials:
/info
, request is successful but registry is empty""
(see related Podman issue)testcontainers/ryuk:0.7.0
-> no registry""
default value""
)artifactory.mycompany.com
url.Parse()
keyURL.Host == reg
matches, because parsing a scheme-less URL results in an empty hostI think handling scheme-less URL's in the host based matching would be the correct thing to do here, and I'm happy to provide a fix if maintainers agree.
The text was updated successfully, but these errors were encountered: