This tutorial shows you how to use the atlas deployments command to
create a local Atlas deployment. In this tutorial, we will deploy a
single-node replica set on your local computer. You can then manage
your deployment, and use Atlas Search and Atlas Vector Search.
Supported OS for Local Atlas Deployments
Operating System | Operating System Version | Architecture | Minimum CPU Cores | Minimum Free RAM (GB) |
|---|---|---|---|---|
MacOS | 13.2 and later | x86-64, ARM | 2 | 2 |
Red Hat Enterprise Linux / CentOS | 8, 9 | x86-64, ARM | 2 | 2 |
Ubuntu | 22.04, 24.04 | x86-64, ARM | 2 | 2 |
Debian | 11, 12 | x86-64, ARM | 2 | 2 |
Amazon Linux | 2023 | x86-64, ARM | 2 | 2 |
Windows | 10, 11 | x86 | 2 | 2 |
Complete the Prerequisites
Before you begin, complete the following prerequisites:
Important
For compatibility information on each product in the dependencies list, see the product's installation documentation.
Install the dependencies.
Install the Atlas CLI.
If you use Homebrew, you can run the following command in your terminal:
brew install mongodb-atlas-cli For installation instructions on other operating systems, see Install or Update the Atlas CLI.
Install Docker.
Docker requires a network connection for pulling and caching MongoDB images.
For MacOS or Windows, install Docker Desktop v4.31+.
For Linux, install Docker Engine v27.0+.
For Linux RHEL, you can also use Podman v5.0+.
(Optional) Install mongosh version 2.0 or later.
brew install mongosh For installation instructions on other operating systems, see Install mongosh.
(Optional) Install Compass version 1.39.4 or later.
brew install mongodb-compass For installation instructions on other operating systems, see Download and Install Compass.
(Optional) Install Visual Studio Code and MongoDB for VS Code Extension.
To learn more, see Install MongoDB for VS Code Extension.
Create an Atlas account.
If you don't already have an existing Atlas account, run atlas setup in your terminal
or create a new account.
Create a Local Atlas Deployment
Use the atlas deployments command to create a local Atlas
deployment.
You can run this command in the following ways:
Interactive Mode (Default): the command prompts you for the deployment settings and provides default values.
Interactive Mode (Custom): the command prompts you for the deployment settings and lets you provide custom values.
Non-Interactive Mode: you run the command with the specified options. The command does not prompt you to provide further values. To learn all of the actions that
atlas deploymentssupports, seeatlas-deployments.
Click one of the following tabs to see the command for your preferred mode.
Run the atlas deployments command in interactive mode.
atlas deployments setup
To initialize the local Atlas deployment with your own data and indexes:
Copy the following command:
atlas deployments setup --initdb {folder} Replace the
{folder}placeholder with the directory that contains the.jsand.shfiles to run inside the local container in alphanumeric order.Run the command.
Specify how to set up your local Atlas database.
Example:
Specify default - With default settings and press
Enter..
? How do you want to setup your local MongoDB database? [Use arrows to move, type to filter] default - With default settings custom - With custom settings cancel - Cancel set up
Creating your deployment local50 [this might take several minutes] 1/4: Downloading and completing configuration... 2/4: Starting your local environment... 3/4: Downloading MongoDB binaries to your local environment... 4/4: Creating your deployment local50... Deployment created! Connection string: mongodb://localhost:27017/?directConnection=true
Run the atlas deployments command in interactive mode.
atlas deployments setup
To initialize the local Atlas deployment with your own data and indexes:
Copy the following command:
atlas deployments setup --initdb {folder} Replace the
{folder}placeholder with the directory that contains the.jsand.shfiles to run inside the local container in alphanumeric order.Run the command.
Run the atlas deployments command with the options.
Example:
atlas deployments setup myLocalRs1 --type local --force
[Default Settings] Deployment Name myLocalRs1 MongoDB Version 7.0 Port 49684 Creating your deployment myLocalRs1 1/2: Starting your local environment... 2/2: Creating your deployment myLocalRs1... Deployment created! Connection string: mongodb://localhost:49684/?directConnection=true connection skipped
To initialize the local Atlas deployment with your own data and indexes:
Copy the following command:
atlas deployments setup myLocalRs1 --type local --force --initdb {folder} Replace the
{folder}placeholder with the directory that contains the.jsand.shfiles to run inside the local container in alphanumeric order.Run the command.
Manage a Local Atlas Deployment
Use the atlas deployments command to manage a local Atlas
deployment. You can use the following commands for both local and
cloud Atlas deployments. You can use --type local or
--type atlas to run the command for local or cloud
atlas deployments respectively.
Download and load the sample data.
Run the following command to download the sample data:
curl https://atlas-education.s3.amazonaws.com/sampledata.archive -o sampledata.archive Copy and paste the following command into your terminal and replace
{port-number}with the port for your deployment:mongorestore --archive=sampledata.archive --port={port-number}
Connect to a deployment.
Run the following command to connect to a deployment:
atlas deployments connect Specify the deployment to connect to and press
Enter..Specify how you want to connect to the deployment and press
Enter..You can retrieve the connection string or connect to the following clients: connection string:
MongoDB Compass if you installed Compass
Visual Studio Code if you installed Visual Studio Code, Visual Studio Code CLI, and MongoDB for VS Code Extension
Delete an Atlas Deployment
Run the following command to delete a deployment:
atlas deployments delete Specify the deployment to delete and press
Enter..Specify
yand pressEnter. to confirm.
Move a Local Atlas Deployment to a Cloud Atlas Deployment
You can use Docker and MongoDB Database Tools to move a local Atlas deployment to a cloud Atlas deployment.
Create a local Atlas deployment.
atlas deployments setup --type local
To initialize the local Atlas deployment with your own data and indexes:
Copy the following command:
atlas deployments setup --type local --initdb {folder} Replace the
{folder}placeholder with the directory that contains the.jsand.shfiles to run inside the local container in alphanumeric order.Run the command.
Create a binary file of the data.
Copy the following command:
docker exec -u root -it {local_deployment_name} sh -c "mkdir -p /data/dump && chown -R mongod:mongod /data/dump && mongodump --archive=/data/dump/dump.archive" Replace the
{local-deployment-name}placeholder with the name of your local Atlas deployment.Run the command.
Update a Local Atlas Deployment
You can use Docker and MongoDB Database Tools to update a local Atlas deployment to a newer version of the image.
Create a new local Atlas deployment.
atlas deployments setup --type local
To initialize the local Atlas deployment with your own data and indexes:
Copy the following command:
atlas deployments setup --type local --initdb {folder} Replace the
{folder}placeholder with the directory that contains the.jsand.shfiles to run inside the local container in alphanumeric order.Run the command.
Create a binary file of the data.
Copy the following command:
docker exec -u root -it {old-local-deployment-name} sh -c "mkdir -p /data/dump && chown -R mongod:mongod /data/dump && mongodump --archive=/data/dump/dump.archive" Replace the
{old-local-deployment-name}placeholder with the name of your old local Atlas deployment.Run the command.
Use Atlas Search with a Local Atlas Deployment
Use the atlas deployments search indexes create command to
create an Atlas Search search index. You can then run Atlas Search queries. To
learn more, see Atlas Search.
You can run this command with local and cloud Atlas deployments. For detailed steps, see Create an Atlas Search Index and Run a Query.
Use Atlas Vector Search with a Local Atlas Deployment
Use the atlas deployments search indexes create command to work
with Atlas Vector Search. To learn more, see
How to Index Vector Embeddings for Vector Search.
You can run this command with local and cloud Atlas deployments. For detailed steps, see Use Atlas Vector Search with an Atlas Deployment.
Important
To use the Atlas CLI with Atlas Vector Search, you must create an Atlas deployment with MongoDB 7.0.5 or later. If you created a local Atlas deployment with an earlier MongoDB version, you don't get the latest MongoDB version automatically. You must delete the earlier images and deployments. Then you must create a new Atlas deployment.
Use Preview Features with a Local Atlas Deployment
The preview version of MongoDB Atlas Local includes support for
Atlas Vector Search Automated Embedding and other advanced Atlas Search community features. To use these
features, set the MONGODB_ATLAS_LOCAL_PREVIEW environment variable
to true before creating your local deployment.
Important
The preview image is intended for testing and development purposes. Preview features might change at any time during the Preview period. To learn more, see Preview Features.
Prerequisites
Before you use preview features with a local Atlas deployment, complete the following prerequisites:
Obtain a Voyage AI API key for Atlas Vector Search Automated Embedding features. To learn more, see API Keys in the Voyage AI documentation.
Complete all prerequisites in Complete the Prerequisites.
Enable Preview Features
To enable preview features in your local deployment:
Set the required environment variables.
Set the MONGODB_ATLAS_LOCAL_PREVIEW environment variable to
true and provide your Voyage AI API key:
export MONGODB_ATLAS_LOCAL_PREVIEW=true export MONGODB_ATLAS_LOCAL_VOYAGE_API_KEY=<your-voyage-api-key>
$env:MONGODB_ATLAS_LOCAL_PREVIEW="true" $env:MONGODB_ATLAS_LOCAL_VOYAGE_API_KEY="<your-voyage-api-key>"
set MONGODB_ATLAS_LOCAL_PREVIEW=true set MONGODB_ATLAS_LOCAL_VOYAGE_API_KEY=<your-voyage-api-key>
Replace <your-voyage-api-key> with your actual Voyage AI API key.
Use Atlas Vector Search Automated Embedding features.
After your deployment is created, you can use Atlas Vector Search Automated Embedding features to automatically generate embeddings using the specified Voyage AI model for your text at index-time and query-time. To learn more, see Create Embeddings Automatically.
To learn more about the environment variables, see Atlas CLI Environment Variables.
Supported Actions
To learn all of the actions that atlas deployments supports, see
atlas-deployments.
Troubleshoot Errors
To learn more about troubleshooting local Atlas deployment issues, see Troubleshoot Local Atlas Deployment Issues.