Use shared container networks
mainTo allow multiple containers to communicate with each other, attach them to a shared network using Testcontainers::Network::SHARED (or Testcontainers::Network.shared). This singleton network persists for the lifetime of your test suite and is cleaned up automatically when the process exits.
network = Testcontainers::Network::SHARED
redis = Testcontainers::DockerContainer.new("redis:6.2-alpine").with_network(network)
nginx = Testcontainers::DockerContainer.new("nginx:alpine").with_network(network)