1. Help Center
  2. Compatibility with Docker

How to use fixed ports for publishing container ports?

Testcontainers Cloud doesn't support fixed ports configuration, please consider using randomized ports.

Testcontainers Cloud client application randomizes through which local ports you can access the exposed ports of the Docker containers. It doesn't support fixed ports configuration. Using Testcontainers with fixed ports is not a best practice, it exposes your tests to race conditions on startup, port conflicts, and other reasons for nondeterministic test failures. Please consider not using fixed ports even when you are not using Testcontainers Cloud.