@@ -100,6 +100,10 @@ deployment with `Docker Compose <https://docs.docker.com/compose/>`__.
100
100
.. procedure::
101
101
:style: normal
102
102
103
+ .. step:: Install and start Docker.
104
+
105
+ To learn more, see the `Docker documentation <https://docs.docker.com/desktop/install/mac-install/>`__.
106
+
103
107
.. step:: Install Docker Compose.
104
108
105
109
**Example:**
@@ -108,6 +112,9 @@ deployment with `Docker Compose <https://docs.docker.com/compose/>`__.
108
112
109
113
brew install docker-compose
110
114
115
+ To learn more, see the `Docker Compose install documentation
116
+ <https://docs.docker.com/compose/install/>`__.
117
+
111
118
.. step:: Create a ``docker-compose.yaml`` file.
112
119
113
120
a. Create the ``docker-compose.yaml`` file in the same directory
@@ -167,6 +174,142 @@ deployment with `Docker Compose <https://docs.docker.com/compose/>`__.
167
174
168
175
mongosh mongodb://root:root@localhost:27778/?directConnection=true
169
176
177
+ Persist Data Across Runs with Docker Compose
178
+ --------------------------------------------
179
+
180
+ You can persist data across multiple runs with `Docker Compose
181
+ <https://docs.docker.com/compose/>`__. Persisting data helps to ensure
182
+ that data isn't lost between runs. Data remains available across runs
183
+ of Docker Compose.
184
+
185
+ .. procedure::
186
+ :style: normal
187
+
188
+ .. step:: Install and start Docker.
189
+
190
+ To learn more, see the `Docker documentation <https://docs.docker.com/desktop/install/mac-install/>`__.
191
+
192
+ .. step:: Install Docker Compose.
193
+
194
+ **Example:**
195
+
196
+ .. code-block:: sh
197
+
198
+ brew install docker-compose
199
+
200
+ To learn more, see the `Docker Compose install documentation
201
+ <https://docs.docker.com/compose/install/>`__.
202
+
203
+ .. step:: Create a script to start and stop your local deployment.
204
+
205
+ a. Create the following ``entrypoint.sh`` script file in the same
206
+ directory that you run Docker Compose from:
207
+
208
+ .. code-block:: sh
209
+
210
+ #!/bin/bash
211
+ stop_atlas() {
212
+ echo "Stopping Atlas deployment..."
213
+ atlas deployments stop
214
+ }
215
+ start_atlas() {
216
+ echo "Starting Atlas deployment..."
217
+ atlas deployments start
218
+ }
219
+ trap 'stop_atlas' SIGTERM SIGINT
220
+ deployment_status=$(atlas deployments list | grep 'LOCAL')
221
+ if [[ -z "$deployment_status" ]]; then
222
+ echo "No local deployment found. Setting up..."
223
+ atlas deployments setup dev --bindIpAll --username root --password $LOCALDEV_PASSWORD --type local --port 27017 --force
224
+ else
225
+ if [[ $deployment_status == *"STOPPED"* ]]; then
226
+ start_atlas
227
+ fi
228
+ fi
229
+ while true
230
+ do
231
+ tail -f /dev/null & wait ${!}
232
+ done
233
+
234
+ #. Run the following command to make the script executable only
235
+ by you:
236
+
237
+ .. code-block:: sh
238
+
239
+ chmod u+x entrypoint.sh
240
+
241
+ .. step:: Update your ``docker-compose.yaml`` file.
242
+
243
+ a. Update the ``docker-compose.yaml`` file to mount the necessary
244
+ data directories as volumes.
245
+
246
+ **Example:**
247
+
248
+ .. code-block:: sh
249
+ :linenos:
250
+
251
+ services:
252
+ mongo:
253
+ image: mongodb/atlas
254
+ privileged: true
255
+ volumes:
256
+ - data-cni:/etc/cni
257
+ - data-containers:/var/lib/containers
258
+ - ./entrypoint.sh:/entrypoint.s
259
+ ports:
260
+ - 27017:27017
261
+ environment:
262
+ - LOCALDEV_PASSWORD={your-password}
263
+ volumes:
264
+ data-cni:
265
+ data-containers:
266
+
267
+ #. Replace the ``{your-password}`` variable in the example with
268
+ your password and save the file.
269
+
270
+ To learn more about the available options, see
271
+ :ref:`atlas-deployments-setup`.
272
+
273
+ .. step:: Run Docker Compose.
274
+
275
+ The following command creates a local |service| deployment with
276
+ |fts| capabilities enabled. It also returns a connection string.
277
+
278
+ **Example:**
279
+
280
+ .. code-block:: sh
281
+
282
+ docker-compose up
283
+
284
+ You can also run Docker Compose in `detached mode <https://docs.docker.com/reference/cli/docker/compose/up/#options>`__.
285
+
286
+ **Example:**
287
+
288
+ .. code-block:: sh
289
+
290
+ docker-compose up -d
291
+
292
+ .. step:: Connect to the local |service| deployment.
293
+
294
+ To connect to the local |service| deployment from the host (not
295
+ container), copy and paste the following command, and replace
296
+ the ``{connection_string}`` variable with your connection string.
297
+
298
+ .. note::
299
+
300
+ The following example uses {+mongosh+}, but you can use the
301
+ connection method that you prefer.
302
+
303
+ .. code-block:: sh
304
+
305
+ mongosh {connection_string}
306
+
307
+ **Example:**
308
+
309
+ .. code-block:: sh
310
+
311
+ mongosh mongodb://root:{your-password}@localhost:27017/?directConnection=true
312
+
170
313
Supported Actions
171
314
-----------------
172
315
0 commit comments