Learn how to override Docker images and configure self-hosted services
Every self-hosted System-X service in TNB uses a default Docker image. You can override these images without modifying source code using system properties.
Each service that implements WithDockerImage interface defines a default image:
public abstract class MongoDB implements Service, WithDockerImage { public String defaultImage() { return "quay.io/mongodb/mongodb-community-server:7.0"; }}
This default is used unless overridden by configuration.
Choose between different distributions of the same service:
MongoDB
PostgreSQL
Kafka
# Official MongoDB imagetnb.mongodb.image=mongo:7.0# Red Hat MongoDB imagetnb.mongodb.image=registry.access.redhat.com/rhscl/mongodb-36-rhel7# Bitnami MongoDB imagetnb.mongodb.image=bitnami/mongodb:7.0
# Official PostgreSQLtnb.postgresql.image=postgres:16# Alpine-based (smaller size)tnb.postgresql.image=postgres:16-alpine# PostGIS-enabledtnb.postgresql.image=postgis/postgis:16-3.4
# Confluent Kafkatnb.kafka.image=confluentinc/cp-kafka:7.5.0# Apache Kafkatnb.kafka.image=apache/kafka:3.6.0# Red Hat AMQ Streamstnb.kafka.image=registry.redhat.io/amq-streams/kafka-36-rhel8:2.6.0
# Connect to external Kafkatnb.kafka.host=kafka.example.com:9092# Connect to external MongoDBtnb.mongodb.host=mongodb.example.com:27017# Connect to external PostgreSQLtnb.postgresql.host=postgres.example.com:5432
When tnb.<service>.host is set, TNB skips deployment and connects to the specified host.
The service must be accessible from your test environment. Ensure network connectivity and firewall rules allow access.
# Use external Kafka clustertnb.kafka.host=kafka-prod.company.com:9092# Other services deployed locallytnb.mongodb.image=mongo:7.0tnb.postgresql.image=postgres:16
Image overrides work with OpenShift deployments too:
# Deploy to OpenShifttest.use.openshift=true# Use custom images in OpenShifttnb.kafka.image=registry.redhat.io/amq-streams/kafka-36-rhel8:2.6.0tnb.mongodb.image=registry.access.redhat.com/rhscl/mongodb-36-rhel7# OpenShift connectionopenshift.kubeconfig=~/.kube/configopenshift.namespace=test-services
# Test with PostgreSQL 15mvn test -Dtest.properties=postgres-15.properties# Test with PostgreSQL 16mvn test -Dtest.properties=postgres-16.properties
test.properties
# Pull images from private registrytnb.mongodb.image=registry.company.com/mongodb:7.0tnb.kafka.image=registry.company.com/kafka:3.6.0tnb.postgresql.image=registry.company.com/postgres:16# Other test configurationtest.use.openshift=falsetest.credentials.file=~/credentials.yaml
# Authenticate to registrydocker login registry.company.com# Run testsmvn test
test.properties
# External production Kafkatnb.kafka.host=kafka-prod.company.com:9092# Local test databases with custom imagestnb.mongodb.image=mongo:7.0tnb.postgresql.image=postgres:16-alpinetnb.redis.image=redis:7-alpine# OpenShift for application under testtest.use.openshift=trueopenshift.kubeconfig=~/.kube/config
test.properties
# Deploy to OpenShifttest.use.openshift=trueopenshift.kubeconfig=~/.kube/configopenshift.namespace=tnb-testing# Use Red Hat certified imagestnb.kafka.image=registry.redhat.io/amq-streams/kafka-36-rhel8:2.6.0tnb.mongodb.image=registry.access.redhat.com/rhscl/mongodb-36-rhel7tnb.postgresql.image=registry.redhat.io/rhel8/postgresql-13:latest# Credentialstest.credentials.use.vault=truetest.credentials.vault.address=https://vault.company.comtest.credentials.vault.token=${VAULT_TOKEN}