-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support custom Docker images in the JDBC URL #4
Comments
I was looking into this yesterday - would be keen to get your thoughts and the ideas from folks in your team. Right now, I think if you have a custom container class with image name of the form An alternative would be a way to provide private registry hostname/credentials in some way, but this either needs to be encoded in the JDBC URL (getting busy) or as environment variables (less discoverable; requires more documentation). What do you think? |
@outofcoffee, @haines, any thoughts? |
I think adding more JDBC URL query string parameters is ok for private registry hostname/credentials. |
I guess it depends on where the private registry is and how they implement authentication. I know with docker, you can authenticate via the command line: docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS Then you can docker push or pull |
I think this is sufficiently complex that we should leave it for a little On Fri, Jun 26, 2015 at 9:17 AM, gusohal notifications@github.com wrote:
|
Would like to see if @rnorth's suggestion works - if so, this seems like a sensible (and standard AFA Docker syntax is concerned) solution. |
We need to try this out - sometime soon! |
This may need further work before it is ready, see #70:
|
This is now implemented - see #99 |
I re-opened the issue (4th issue of the project!) since it was talking about using custom images in the JDBC URL and it is still not implemented :D |
ContextExample URL: Problem 1We cannot easily change it to Problem 2Custom registries (e.g. Ideade-couple the driver & image and introduce aliases: // Must be called before using the URL
JdbcContainer.registerAlias("corporate-mysql", "mysql", "registry.my.corp:5000/foo/custom-mysql");
// And then start it with:
String jdbcUrl = "jdbc:tc:corporate-mysql:5.6.23:///databasename"; Where: public static void registerAlias(String aliasName, String driverId, String imageName); We could also add it to testcontainers.properties for those who don't want to use static methods |
I had a discussion with @bsideup in Slack about this because I just recognized that testcontainers.properties are not considered for mysql module, while I was trying to overwrite mysql.container.image = mysql:8.0.19 IMHO aliases are a possibility, but I'm not sure if it's necessary. |
I think I like @bsideup's suggestion. I suspect that configuring via But having the static method to register aliases offers some power too - it means that it's possible to look up an image using custom code, or even build one on the fly with |
@rnorth , @bsideup Code approach: testcontainers.properties: |
@SaschaJohn Very glad to see your commit. I just stumbled on this issue yesterday when I tried using a custom postgres image which includes the tableversion extension. Is there a way for me to try "nightly" builds? I'd like to try this out, and provide feedback. |
@binkley the PR is not merged yet, but you can use http://jitpack.io to obtain a version of that code to test it without having to compile/install it yourself, just use More info here: |
See testcontainers/testcontainers-java#4 for in-progress solution to custom images with JDBC.
@binkley looking forward for feedback :) |
@SaschaJohn Sorry for the slow reply. I've been struggling getting the dependencies working.
Since I still see "java.lang.IllegalArgumentException: JDBC URL matches jdbc:tc: prefix but the database or tag name could not be identified", it looks like I'm not using your PR branch version of I'm still poking at it. |
This PR adds support for [R2DBC](https://r2dbc.io). ## URL support The URL support is similar to the JDBC's, but: 1. Does not reuse containers by URL - it is unclear yet how to "hash" `ConnectionFactoryOptions` 1. The image tag must be explicitly provided via `TC_IMAGE_TAG` r2dbc option 1. TODO: daemon mode 1. TODO: alias support (see #4) ## Example usage The user **must add the `org.testcontainers:r2dbc` module** - unlike JDBC, we use `compileOnly` dependency on R2DBC, since it is a 3rd party dependency. Once both the `r2dbc` and database's module are added, one can use: ```java String url = "r2dbc:tc:postgresql:///db?TC_IMAGE_TAG=10-alpine"; ConnectionFactory connectionFactory = ConnectionFactories.get(url); ``` ## Programmatic access For those who start containers manually and want to obtain `ConnectionFactoryOptions` for already started containers, we provide a helper static method: ```java try (PostgreSQLContainer<?> container = new PostgreSQLContainer<>()) { container.start(); ConnectionFactory connectionFactory = ConnectionFactories.get( PostgreSQLR2DBCDatabaseContainer.getOptions(container) ); } ```
This PR adds support for [R2DBC](https://r2dbc.io). ## URL support The URL support is similar to the JDBC's, but: 1. Does not reuse containers by URL - it is unclear yet how to "hash" `ConnectionFactoryOptions` 1. The image tag must be explicitly provided via `TC_IMAGE_TAG` r2dbc option 1. TODO: daemon mode 1. TODO: alias support (see #4) ## Example usage The user **must add the `org.testcontainers:r2dbc` module** - unlike JDBC, we use `compileOnly` dependency on R2DBC, since it is a 3rd party dependency. Once both the `r2dbc` and database's module are added, one can use: ```java String url = "r2dbc:tc:postgresql:///db?TC_IMAGE_TAG=10-alpine"; ConnectionFactory connectionFactory = ConnectionFactories.get(url); ``` ## Programmatic access For those who start containers manually and want to obtain `ConnectionFactoryOptions` for already started containers, we provide a helper static method: ```java try (PostgreSQLContainer<?> container = new PostgreSQLContainer<>()) { container.start(); ConnectionFactory connectionFactory = ConnectionFactories.get( PostgreSQLR2DBCDatabaseContainer.getOptions(container) ); } ```
This is how we solved it for postgres:
Added that container class to src\test\resources\META-INF\services\org.testcontainers.containers.JdbcDatabaseContainerProvider And then just declare your DB url with postgresqlext: |
any updates so far regarding azure-sql-edge with MSSQLServerContainer ? |
Make it possible to specify a full docker image name in the JDBC URL and/or custom docker registries, and these might be necessary to allow teams to use their own privately managed images.
The text was updated successfully, but these errors were encountered: