I want to use a local-only Docker image with testcontainers.
The code looks like this:
new GenericContainer("rserver:latest")...
However it looks like another image with same name is fetched from a remote registry.
How can I force testcontainers to use a local image?
Kubernetes use local docker image is nothing but create Kubernetes image locally and deploy the same on Kubernetes cluster locally; the first step is to deploy our application on Kubernetes to build the docker image. Next, we need to use minikube to run the Kubernetes in our local environment.
In order to use Testcontainers in a Gitlab CI pipeline, you need to run the job as a Docker container (see Patterns for running inside Docker).
The classpath testcontainers. properties file may exist within the local codebase (e.g. within the src/test/resources directory) or within library dependencies that you may have. Any such configuration files will have their contents merged.
I know this answer is too late but it can be useful for others who has exactly the same issue.
If you are already have the image you want, try to implicitly set the image Pull Policy for your container to default:
GenericContainer container = new GenericContainer("someImage")
.withImagePullPolicy(PullPolicy.defaultPolicy());
The default image Pull Policy tells the Docker to pull the image from a remote repository only if it does not exist locally.
Note that this method (withImagePullPolicy(..)) is available only with latest versions of TestContainers dependency. I use 1.14.3.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With