Skip to content

Conversation

chaindead
Copy link

@chaindead chaindead commented Aug 25, 2025

Summary

This PR adds first-class support for pulling container images from private registries

Motivation

Gnomock is often used in CI and enterprise environments where base images are mirrored or hosted in private registries for security and reliability. Today, the Postgres preset hardcodes the Docker Hub library image, which makes using private registries cumbersome or impossible without custom forks.

Chages is fully backward-compatible:

  • If ImageName is not set, the preset behaves exactly as before.
  • Existing configs and tests do not need changes.

Usage

  • Continue using the preset as before for public images.
  • To use a private registry, set ImageName to your registry path and keep Version:
    • Example: WithImage("registry.example.com/team/postgres").WithVersion("16.2")
  • Authentication and access control rely on the testcontainers setup(via ENV for example)

Request for early feedback

If maintainers are comfortable with this structure, I will implement the same pattern for other presets (e.g., MySQL, MongoDB, Redis, etc.) in this PR

Open questions

  • Is naming acceptible?
  • Do you want a note in the preset README about private registry setup?

@chaindead
Copy link
Author

@orlangure , when you have a moment, could you please take a look at this PR? Let me know if anything needs clarification.

Thanks! 😊

@orlangure
Copy link
Owner

Hey @chaindead, sorry for not seeing this in time.
Thank you for bringing this up, but first, can you try using the below option instead and let me know if it works for you?

gnomock/options.go

Lines 216 to 222 in fa40087

// WithCustomImage allows to define a custom image name. This option should be used to
// override the image registry and repository defined by presets.
func WithCustomImage(image string) Option {
return func(o *Options) {
o.CustomImage = image
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants