feat: add Docker registry authentication support #44
+499
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive Docker registry authentication support to testcontainers-php, allowing users to pull private images from registries like GitHub Container Registry, Docker Hub, and custom registries.
Changes
DockerAuthConfigclass to handle authentication configurationDOCKER_AUTH_CONFIGenvironment variable~/.docker/config.jsonpullImage()method to use authentication when availableMotivation
Currently, when pulling private Docker images, authentication must be hardcoded in the
pullImage()method. This PR implements the same authentication mechanisms as the Docker CLI, making it seamless for users to work with private registries.Usage Examples
Using DOCKER_AUTH_CONFIG environment variable
Using Docker config file
The library will automatically read from
~/.docker/config.jsonifDOCKER_AUTH_CONFIGis not set.Using credential stores
{ "auths": { "ghcr.io": {} }, "credsStore": "osxkeychain" }Test plan
🤖 Generated with Claude Code