For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

Install or Uninstall MongoDB Search on Community in a Docker Container

You can install the search process, mongot, in MongoDB Community Edition. The search process is available for deployment as an image in Docker. The mongot process supports full-text search and semantic search with your own embeddings or automated embeddings.

Note

To onboard more quickly with a deployment meant for experimentation, see the following tutorials for Self-Managed deployments:

Before you deploy mongot, you must complete the following steps:

  1. Install Docker and Docker Compose.

  2. If you want MongoDB Vector Search to automatically generate embeddings for text data in your collection, create endpoint service API keys. To learn more, see Automated Embedding.

    Important

    Automated Embedding is in Preview. The feature and corresponding documentation might change at any time during the Preview period. To learn more, see Preview Features.

    If you don't already have the keys, create the endpoint service API keys from the Atlas UI. We recommend that you create two keys, one for generating embeddings at index-time and another for generating embeddings at query-time, from two Atlas projects.

    Note

    Your provider endpoint for generating embeddings depends on whether you create the API keys from the Atlas UI or directly from Voyage AI.

Warning

This procedure provides a simple and insecure default configuration that does not enable access control. The steps create a deployment intended for local experimentation only.

Before exposing these containers and using your setup in production, see the following resources to secure your deployment:

1

To pull the mongot Docker image, run the following command:

docker pull mongodb/mongodb-community-search:latest

To verify the image is on your Docker Desktop, run the following command:

docker image ls mongodb/mongodb-community-search
2

To create a docker network for inter-container communication between the database and search containers, run the following command:

docker network create search-community
3

To download the MongoDB Docker image, run the following command:

docker pull mongodb/mongodb-community-server:latest

Note

You must have a minimum of MongoDB 8.2+ to use MongoDB Search with an on-prem deployment. For more information, see MongoDB Search Compatibility.

For additional details on installing MongoDB with Docker, see Install MongoDB Community with Docker.

4

Create a password file for mongot to connect to mongod.

For example, select your operating system and replace <mongot_password> with your password. Then, run the following command to create a file called passwordFile:

echo -n "<mongot_password>" > passwordFile
chmod 400 passwordFile

Note

The -n flag prevents a trailing newline.

5

To create your configuration file, save the following code to mongod.conf or your preferred location.

# MongoDB Configuration File
# Network configuration
net:
port: 27017
bindIpAll: true # Equivalent to --bind_ip_all
# Replica set configuration
replication:
replSetName: rs0
# Search configuration parameters
setParameter:
# Server parameters to advise mongod of mongot availability for search index management and querying
searchIndexManagementHostAndPort: mongot-community.search-community:27028
mongotHost: mongot-community.search-community:27028
skipAuthenticationToSearchIndexManagementServer: false
useGrpcForSearch: true
searchTLSMode: disabled
6

To start the mongod:

  • Replace <your_admin_username> with the username you want to specify for your admin user.

  • Replace <your_admin_password> with the password you want to specify for your admin user.

  • Replace </path/to/data/db> with the path to the local directory for the mounted volume.

  • Replace </path/to/mongod.conf> with the path to the configuration file you created above.

docker run --rm \
--name mongod \
-v </path/to/mongod.conf>:/etc/mongod.conf:ro \
-v </path/to/data/db>:/data/db \
-p 27017:27017 \
--network search-community \
mongodb/mongodb-community-server:latest \
--config /etc/mongod.conf \
--replSetMember=mongod.search-community:27017
7

Run the following command to connect to the mongod instance you started on port 27017, replacing <your_admin_username> and <your_admin_password> with the username and password you created for your admin user.

docker exec -it mongod mongosh --port 27017
8

mongot must be able to connect to your MongoDB deployment through a user with the searchCoordinator role.

Run the following command to connect to the admin database:

use admin

To create a user with the searchCoordinator role:

  • Replace <your-mongot-username> with a username for your mongot user.

  • Replace <your-mongot-password> with the password that you specified in your passwordFile in step 5.

  • Run the following command:

db.createUser(
{
user: "<mongot_username>",
pwd: "<mongot_password>",
roles: [ "searchCoordinator" ]
}
)

For more information on creating users, see Create a User on Self-Managed Deployments.

9

You can configure mongot with a YAML configuration file. You must specify the username that you specified in the previous step as the syncSource.replicaSet.username. You must also specify the passwordFile that you created in the previous step as the syncSource.replicaSet.passwordFile.

For more information on mongot configuration options, see mongot Options.

For example, you can adapt the settings to your local configuration as shown below:

# mongot.conf
syncSource:
replicaSet:
hostAndPort: "mongod.search-community:27017"
scramAuth:
username: "mongotUser"
passwordFile: "/passwordFile"
authSource: "admin"
tls:
enabled: false
replicationReader:
readPreference: "secondaryPreferred"
storage:
dataPath: "/data/mongot"
server:
grpc:
address: "mongot-community.search-community:27028"
tls:
mode: "disabled"
metrics:
enabled: true
address: "mongot-community.search-community:9946"
healthCheck:
address: "mongot-community.search-community:8080"
logging:
verbosity: INFO

Save your file to mongot.config or your preferred file location.

Both containers run on the same search-community Docker network.

10

To start the Search in Community binary, mongot:

  • Replace </path/to/data/mongot> with the path to the local directory for the mounted volume to store mongot data.

  • Replace </path/to/mongot.conf> with the path to the mongot configuration file that you created in the previous step.

  • Replace </path/to/passwordFile> with the path to the password file you created.

docker run --rm \
--name mongot-community \
-v </path/to/data/mongot>:/data/mongot \
-v </path/to/mongot.conf>:/mongot-community/config.default.yml \
-v </path/to/passwordFile>:/passwordFile:ro \
--network search-community \
-p 8080:8080 \
-p 9946:9946 \
mongodb/mongodb-community-search:latest

This command:

  • Mounts the volume.

  • Mounts a configuration file from a local volume.

  • Specifies the port range.

  • Exposes the metrics port.

  • Starts the container on the search-community Docker network with a container named mongot-community.

11

To verify, send a request by using a HTTP client or curl to the /health endpoint. For example, send a curl request similar to the following sample request:

curl localhost:8080/health

The endpoint returns one of the following in the response:

  • SERVING, if the mongot process is running

    mongot might not serve queries as it doesn't check the status of the indexes, which must be in Ready state to serve queries.

  • NOT_SERVING, if the mongot process isn't running

For more information, see Verify Your mongot Connection.

To completely remove MongoDB Search and MongoDB Vector Search from a system, remove the container image, the configuration files, and any data or log directories. The following section guides you through the necessary steps.

1

To drop the mongotUser user, run the following commands:

use admin
db.dropUser("mongotUser")

For details, see db.dropUser().

2

To stop the mongot process, stop the container image running in Docker.

3

To remove the mongot and mongod configuration files, run the following commands using the full path to your configuration files:

rm /path/to/config.default.yml
rm /path/to/mongod.conf
4

To remove the password file, run the following commands using the full path to the password file:

rm /path/to/passwordFile
5

To remove the data directory that stores mongot data, run the following command using the full path to your mongot data directory:

rm /path/to/mongot/data