Mongodb/mongodb-atlas-local occasionally fails to start

Hi,

I’m using mongodb/mongodb-atlas-local:8.0.3 in docker compose locally, in integation tests (using TestContainers) and in github actions.

Every few runs the container fails to start, in which case I need to stop it and try again. This is happening very randomly and I can’t put my finger on what might be causing it.

Since it’s happening in various configuration I assume it’s not OS related etc.

I tried other tags of the image but had the same experience.

Any help would be highly appreciated :smile:

Thanks

Hi @Oran_Halberthal , are you seeing the container fail to start in all three instances (compose, integration tests, and github actions)? Specifically, for Docker Compose does your docker-compose file specify a hostname for the mongodb service, similar to this example?

Hi Jonny_Roberts,

Thanks for looking into this. docker compose runs 3 containers, all of which have a hostname.

This is what a “hang” looks like in github actions logs:

[testcontainers.org 00:00:21.82] Wait for Docker container 8a558415e264 to complete readiness checks

It just sits there until it times out

In local docker, running integration tests, It’s constantly consuming 2-5% CPU while “hanging” and eventually times out.

I tried to attach some log samples but because I’m a new user it didn’t let me

Hi Oran!

I implemented the TestContainers module for the Atlas Local container:
https://java.testcontainers.org/modules/databases/mongodb/#mongodbatlaslocalcontainer

Here’s the code inside that implementation which relates to the health check for the container:

waitingFor(Wait.forSuccessfulCommand("runner healthcheck"));

i.e. we wait for the shell command ‘runner healthcheck’ to return a non-zero response, which happens when MongoT and MongoD are initialised. We don’t rely on the default health check, because the intervals are so large you can end up waiting 30s for it to start (even though it also calls the same runner healthcheck).

Ref: testcontainers-java/modules/mongodb/src/main/java/org/testcontainers/mongodb/MongoDBAtlasLocalContainer.java at main · testcontainers/testcontainers-java · GitHub

I’m interested to know if there is any issue with this TestContainers health check - if it is happening in TestContainers I’d appreciate if you could raise an issue here:

@Jonny_Roberts please also let us know if you see an issue with that wait implementation.

Here’s how I use TestContainers with their nice JUnit annotation:

@Testcontainers
class SomeTest {

   @Container
   private static final MongoDBAtlasLocalContainer mongoDBContainer = new MongoDBAtlasLocalContainer("mongodb/mongodb-atlas-local:8.0.5");

(automatically starts and stops the container for the test class)
Ref: Testing MongoDB Atlas Search Java Apps Using TestContainers - DEV Community

I do recommend updating to the latest patch version of the container too - at time of writing 8.0.9:

mongodb/mongodb-atlas-local:8.0.9

I checked with this latest one with TestContainers and can’t replicate any hang locally.

Cheers,
Luke

Thanks @Luke_Thompson I created issue [Bug]: mongodb/mongodb-atlas-local randomly fails to start · Issue #10267 · testcontainers/testcontainers-java · GitHub with all the details and logs.

I tried updating to mongodb/mongodb-atlas-local:8.0.9 but it didn’t make any difference. Out of the 4 attempts with it 2 succeeded and 2 failed

Both, please let me know if you need any further information from me and I’ll gladly provide it

Hi @Oran_Halberthal , can you add the environment variable to your docker-compose file RUNNER_LOG_FILE=/dev/stdout and share these logs (on the same GitHub issue), as well as the output from docker inspect [container name], please?

@Jonny_Roberts I added the env variable to the test containers config because the issue is happening when I run my integration tests (either locally or in github actions)

Please let me know if this isn’t what you expected.

I added both outputs to the Github issue

1 Like

Thanks @Oran_Halberthal , I’ll review this with the team here and get back asap.

In the meantime, can you just confirm that you’re still seeing the same intermittent failing in all three implementations (Docker Compose, TestContainers, and GitHub Actions), please?

Hi @Jonny_Roberts

I can definitely confirm that I’m seeing it in TestContainers (both locally and in GitHub actions).

As for docker-compose, I don’t tend to restart my laptop very often so the containers, including this one are constantly running in the background

For future users, this was resolved by adding this. Thanks to all who jumped here to help :slightly_smiling_face:

CleanShot 2025-05-21 at 12.57.03@2x

1 Like