You may be running into a Docker bootstrap race condition in your test suite. The test suite should not start until all necessary services are fully bootstrapped. Note that this typically includes more execution than simply starting up the containers. Some DB images create default databases and tables on container start. Selenium containers may require some time to start up the browser.
We suggest dockerize: https://github.com/jwilder/dockerize as a tool for managing container bootstrapping. The `-wait` subcommand will run commands on a sleep loop to test for bootstrap completion. You'll need to determine the appropriate commands to test that each container has fully bootstrapped.
You can see examples of how to use dockerize on our forum: https://discuss.circleci.com/t/prevent-race-conditions-by-waiting-for-services-with-dockerize/11215
Another utility that might be useful is 'Wait Port': https://github.com/dwmkerr/wait-port