| 
 | 1 | +# MongoDB Atlas Local  | 
 | 2 | + | 
 | 3 | +Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 4 | + | 
 | 5 | +## Introduction  | 
 | 6 | + | 
 | 7 | +The MongoDB Atlas Local module for Testcontainers lets you spin up a local MongoDB Atlas instance in Docker using  | 
 | 8 | +[mongodb/mongodb-atlas-local](https://hub.docker.com/r/mongodb/mongodb-atlas-local) for integration tests and  | 
 | 9 | +development. This module supports SCRAM authentication, init scripts, and custom log file mounting.  | 
 | 10 | + | 
 | 11 | +This module differs from the standard modules/mongodb Testcontainers module, allowing users to spin up a full local  | 
 | 12 | +Atlas-like environment complete with Atlas Search and Atlas Vector Search.  | 
 | 13 | + | 
 | 14 | +## Adding this module to your project dependencies  | 
 | 15 | + | 
 | 16 | +Please run the following command to add the MongoDB Atlas Local module to your Go dependencies:  | 
 | 17 | + | 
 | 18 | +```  | 
 | 19 | +go get github.com/testcontainers/testcontainers-go/modules/mongodb/atlaslocal  | 
 | 20 | +```  | 
 | 21 | + | 
 | 22 | +## Usage example  | 
 | 23 | + | 
 | 24 | +<!--codeinclude-->  | 
 | 25 | +[Creating a MongoDB Atlas Local container](../../modules/mongodb/atlaslocal/examples_test.go) inside_block:runMongoDBAtlasLocalContainer  | 
 | 26 | +<!--/codeinclude-->  | 
 | 27 | + | 
 | 28 | +## Module Reference  | 
 | 29 | + | 
 | 30 | +### Run function  | 
 | 31 | + | 
 | 32 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 33 | + | 
 | 34 | +The `atlaslocal` module exposes one entrypoint function to create the MongoDB Atlas Local container, and this  | 
 | 35 | +function receives three parameters:  | 
 | 36 | + | 
 | 37 | +```golang  | 
 | 38 | +func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)  | 
 | 39 | +```  | 
 | 40 | + | 
 | 41 | +- `context.Context`, the Go context.  | 
 | 42 | +- `string`, the Docker image to use.  | 
 | 43 | +- `testcontainers.ContainerCustomizer`, a variadic argument for passing options.  | 
 | 44 | + | 
 | 45 | +#### Image  | 
 | 46 | + | 
 | 47 | +Use the second argument in the `Run` function to set a valid Docker image.  | 
 | 48 | +In example: `Run(context.Background(), "mongodb/mongodb-atlas-local:latest")`.  | 
 | 49 | + | 
 | 50 | +### Container Options  | 
 | 51 | + | 
 | 52 | +When starting the MongoDB Atlas Local container, you can pass options in a variadic way to configure it.  | 
 | 53 | + | 
 | 54 | +#### WithUsername  | 
 | 55 | + | 
 | 56 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 57 | + | 
 | 58 | +This functional option sets the initial username to be created when the container starts, populating the  | 
 | 59 | +`MONGODB_INITDB_ROOT_USERNAME` environment variable. You cannot mix this option with `WithUsernameFile`, as it will  | 
 | 60 | +result in an error.  | 
 | 61 | + | 
 | 62 | +#### WithPassword  | 
 | 63 | + | 
 | 64 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 65 | + | 
 | 66 | +This functional option sets the initial password to be created when the container starts, populating the  | 
 | 67 | +`MONGODB_INITDB_ROOT_PASSWORD` environment variable. You cannot mix this option with `WithPasswordFile`, as it will  | 
 | 68 | +result in an error.  | 
 | 69 | + | 
 | 70 | +#### WithUsernameFile  | 
 | 71 | + | 
 | 72 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 73 | + | 
 | 74 | +This functional option mounts a local file as the MongoDB root username secret at `/run/secrets/mongo-root-username`  | 
 | 75 | +and sets the `MONGODB_INITDB_ROOT_USERNAME_FILE` environment variable. The path must be absolute and exist; no-op if  | 
 | 76 | +empty.  | 
 | 77 | + | 
 | 78 | +#### WithPasswordFile  | 
 | 79 | + | 
 | 80 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 81 | + | 
 | 82 | +This functional option mounts a local file as the MongoDB root password secret at `/run/secrets/mongo-root-password` and  | 
 | 83 | +sets the `MONGODB_INITDB_ROOT_PASSWORD_FILE` environment variable. The path must be absolute and exist; no-op if empty.  | 
 | 84 | + | 
 | 85 | +#### WithNoTelemetry  | 
 | 86 | + | 
 | 87 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 88 | + | 
 | 89 | +This functional option disables the telemetry feature of MongoDB Atlas Local, setting the `DO_NOT_TRACK` environment  | 
 | 90 | +variable to `1`.  | 
 | 91 | + | 
 | 92 | +#### WithInitDatabase  | 
 | 93 | + | 
 | 94 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 95 | + | 
 | 96 | +This functional option allows you to specify a database name to be initialized when the container starts, populating  | 
 | 97 | +the `MONGODB_INITDB_DATABASE` environment variable.  | 
 | 98 | + | 
 | 99 | +#### WithInitScripts  | 
 | 100 | + | 
 | 101 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 102 | + | 
 | 103 | +Mounts a directory into `/docker-entrypoint-initdb.d`, running `.sh`/`.js` scripts on startup. Calling this function  | 
 | 104 | +multiple times mounts only the latest directory.  | 
 | 105 | + | 
 | 106 | +#### WithMongotLogFile  | 
 | 107 | + | 
 | 108 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 109 | + | 
 | 110 | +This functional option writes the mongot logs to `/tmp/mongot.log` inside the container. See  | 
 | 111 | +`(*Container).ReadMongotLogs` to read the logs locally.  | 
 | 112 | + | 
 | 113 | +#### WithMongotLogToStdout  | 
 | 114 | + | 
 | 115 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 116 | + | 
 | 117 | +This functional option writes the mongot logs to `/dev/stdout` inside the container. See  | 
 | 118 | +`(*Container).ReadMongotLogs` to read the logs locally.  | 
 | 119 | + | 
 | 120 | +#### WithMongotLogToStderr  | 
 | 121 | + | 
 | 122 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 123 | + | 
 | 124 | +This functional option writes the mongot logs to `/dev/stderr` inside the container. See  | 
 | 125 | +`(*Container).ReadMongotLogs` to read the logs locally.  | 
 | 126 | + | 
 | 127 | +#### WithRunnerLogFile  | 
 | 128 | + | 
 | 129 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 130 | + | 
 | 131 | +This functional option writes the runner logs to `/tmp/runner.log` inside the container. See  | 
 | 132 | +`(*Container).ReadRunnerLogs` to read the logs locally.  | 
 | 133 | + | 
 | 134 | +#### WithRunnerLogToStdout  | 
 | 135 | + | 
 | 136 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 137 | + | 
 | 138 | +This functional option writes the runner logs to `/dev/stdout` inside the container. See  | 
 | 139 | +`(*Container).ReadRunnerLogs` to read the logs locally.  | 
 | 140 | + | 
 | 141 | +#### WithRunnerLogToStderr  | 
 | 142 | + | 
 | 143 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 144 | + | 
 | 145 | +This functional option writes the runner logs to `/dev/stderr` inside the container. See  | 
 | 146 | +`(*Container).ReadRunnerLogs` to read the logs locally.  | 
 | 147 | + | 
 | 148 | +{% include "../features/common_functional_options_list.md" %}  | 
 | 149 | + | 
 | 150 | +### Container Methods  | 
 | 151 | + | 
 | 152 | +The MongoDB Atlas Local container exposes the following methods:  | 
 | 153 | + | 
 | 154 | + | 
 | 155 | +#### ConnectionString  | 
 | 156 | + | 
 | 157 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 158 | + | 
 | 159 | +The `ConnectionString` method returns the connection string to connect to the MongoDB Atlas Local container.  | 
 | 160 | +It returns a string with the format `mongodb://<host>:<port>[/<db>]/?directConnection=true[&authSource=admin]`.  | 
 | 161 | + | 
 | 162 | +It can be used to configure a MongoDB client (`go.mongodb.org/mongo-driver/v2/mongo`), e.g.:  | 
 | 163 | + | 
 | 164 | +<!--codeinclude-->  | 
 | 165 | +[Using ConnectionString with the MongoDB client](../../modules/mongodb/atlaslocal/examples_test.go) inside_block:connectToMongo  | 
 | 166 | +<!--/codeinclude-->  | 
 | 167 | + | 
 | 168 | +#### ReadMongotLogs  | 
 | 169 | + | 
 | 170 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 171 | + | 
 | 172 | +The `ReadMongotLogs` returns a reader for the log solution specified when constructing the container.  | 
 | 173 | + | 
 | 174 | + | 
 | 175 | +<!--codeinclude-->  | 
 | 176 | +[Using ReadMongotLogs with the MongoDB client](../../modules/mongodb/atlaslocal/examples_test.go) inside_block:mongotLogsRead  | 
 | 177 | +<!--/codeinclude-->  | 
 | 178 | + | 
 | 179 | +#### ReadRunnerLogs  | 
 | 180 | + | 
 | 181 | +- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>  | 
 | 182 | + | 
 | 183 | +The `ReadRunnerLogs` returns a reader for the log solution specified when constructing the container.  | 
 | 184 | + | 
 | 185 | + | 
 | 186 | +<!--codeinclude-->  | 
 | 187 | +[Using ReadRunnerLogs with the MongoDB client](../../modules/mongodb/atlaslocal/examples_test.go) inside_block:runnerLogsRead  | 
 | 188 | +<!--/codeinclude-->  | 
0 commit comments