docker
For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt
<!-- Tab options on this page. Append to the .md URL to filter: ?tabs=<id,...> select specific tabs (e.g. ?tabs=nodejs,shell) ?allTabs=true include every tab (no param) default: one tab per tabset
Available tabs: other tabs: linux_macos, windows -->
Install or Uninstall mongot 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.
Install MongoDB Search and Vector Search with Docker
Note:
To onboard more quickly with a deployment meant for experimentation, see the [MongoDB Search and MongoDB Vector Search Local Development Quickstart.](https://www.mongodb.com/docs/search/self-managed/current/installation/quick-start.md#std-label-mongot-deployment-using-atlas-local
Before You Begin
Important:
mongot syncs data from mongod and requires a MongoDB replica set. A standalone mongod deployment doesn't support mongot.
Before you deploy mongot, complete the following steps:
Install Docker and Docker Compose.
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.](https://www.mongodb.com/docs/vector-search/crud-embeddings/automated-embedding.md#std-label-avs-auto-embeddings
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.
Procedure
Warning:
This procedure provides a minimal 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:
-
[Security Checklist for Self-Managed Deployments](https://www.mongodb.com/docs/manual/administration/security-checklist.md#std-label-security-checklist
-
[Enable Access Control on Self-Managed Deployments](https://www.mongodb.com/docs/manual/tutorial/enable-authentication.md#std-label-enable-access-control
-
[Enforce Keyfile Access Control on Existing Replica Set](https://www.mongodb.com/docs/manual/tutorial/enforce-keyfile-access-control-in-existing-replica-set.md#std-label-security-enable-access-control-replica-set
-
[Configure MongoDB Instances for TLS/SSL Encryption](https://www.mongodb.com/docs/manual/tutorial/configure-ssl.md#std-label-configure-mongod-mongos-for-tls-ssl
-
[Self-Managed Network and Configuration Hardening](https://www.mongodb.com/docs/manual/core/security-hardening.md#std-label-network-config-hardening
-
Pull the
mongotDocker image.
To pull the mongot Docker image, run the following command:
shell
docker pull mongodb/mongodb-community-search:latest
To verify the image is on your Docker Desktop, run the following command:
shell
docker image ls mongodb/mongodb-community-search
- Create a Docker network.
To create a docker network for inter-container communication between the database and search containers, run the following command:
shell
docker network create search-community
- Download the MongoDB Docker image.
To download the MongoDB Docker image, run the following command:
shell
docker pull mongodb/mongodb-community-server:latest
Note:
You must have a minimum of MongoDB 8.3+ 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.
- Create a
mongotsync-user password file.
Create a password file for mongot to connect to mongod. Select your operating system and run the command:
### Linux/MacOS
Replace <mongot_password> with your password and run the following command to create a file called passwordFile in your current directory:
shell
echo -n "<mongot_password>" > passwordFile
chmod 400 passwordFile
Note:
The -n flag prevents a trailing newline.
- Create your mongod configuration file.
To create your configuration file, save the following code to mongod.conf or your preferred location.
```yaml # 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
```
- Start your
mongod.
To start the mongod:
-
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. -
On Windows, replace the backslash (
\) at the end of each line with the line continuation character for your shell. Command Prompt uses a caret (^), and PowerShell uses a backtick.
shell
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
- In a new shell, start
mongosh.
Run the following command to connect to the mongod instance you started on port 27017:
shell
docker exec -it mongod mongosh --port 27017
- Create a user for the
mongotprocess on your MongoDB deployment.
mongot must be able to connect to your MongoDB deployment through a user with the [searchCoordinator](https://www.mongodb.com/docs/manual/reference/built-in-roles.md#mongodb-authrole-searchCoordinator role.
Run the following command to connect to the admin database:
javascript
use admin
To create a user with the searchCoordinator role:
-
Replace
<mongot_username>with a username for yourmongotuser. -
Replace
<mongot_password>with the password that you specified in yourpasswordFilein step 4. -
Run the following command:
javascript
db.createUser(
{
user: "<mongot_username>",
pwd: "<mongot_password>",
roles: [ "searchCoordinator" ]
}
)
For more information on creating users, see [Create a User on Self-Managed Deployments.](https://www.mongodb.com/docs/manual/tutorial/create-users.md#std-label-create-users
- Specify your search configuration options.
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.scramAuth.username. You must also specify the passwordFile that you created in the previous step as the syncSource.replicaSet.scramAuth.passwordFile.
For more information on mongot configuration options, see [mongot Options.](https://www.mongodb.com/docs/manual/reference/configuration-options.md#std-label-mongot-configuration-options
For example, you can adapt the settings to your local configuration as shown below:
```yaml # 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.
-
Start the mongot process.
To start the Search in Community binary (
mongot), select your operating system and run the command:Linux/MacOS
-
Replace
</path/to/data/mongot>with the path to the local directory for the mounted volume to storemongotdata. -
Replace
</path/to/mongot.conf>with the path to themongotconfiguration file that you created in the previous step. -
Replace
</path/to/passwordFile>with the path to the password file that you created.
shell 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:latestThis 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-communityDocker network with a container namedmongot-community.
-
-
Verify the health of the
mongotprocess.To verify, send a request by using a HTTP (HyperText Transport Protocol) client or
curlto the/healthendpoint. For example, send acurlrequest similar to the following sample request:shell curl localhost:8080/healthThe endpoint returns one of the following in the response:
SERVING, if themongotprocess is running
mongotmight not serve queries as it doesn't check the status of the indexes, which must be inReadystate to serve queries.NOT_SERVING, if themongotprocess isn't running
For more information, see [Verify Your mongot Connection.](https://www.mongodb.com/docs/search/self-managed/current/connection/verify-connection.md#std-label-mongot-verify-connection
Uninstall MongoDB Search and MongoDB Vector Search with Docker
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.
- Drop the
mongotuser.
To drop the mongot user, run the following commands, replacing <mongot_username> with the username you created for mongot:
javascript
use admin
db.dropUser("<mongot_username>")
For details, see [db.dropUser().](https://www.mongodb.com/docs/manual/reference/method/db.dropUser.md#mongodb-method-db.dropUser
- Stop the
mongot.
To stop the mongot process, stop the container image running in Docker.
- Remove any configuration files.
To remove the mongot and mongod configuration files, run the following commands using the full path to your configuration files:
bash
rm /path/to/config.default.yml
rm /path/to/mongod.conf
- Remove the password file.
To remove the password file, run the following commands using the full path to the password file:
bash
rm /path/to/passwordFile
- Remove the data directory for
mongot.
To remove the data directory that stores mongot data, run the following command using the full path to your mongot data directory:
bash
rm /path/to/mongot/data
Next Steps
-
Create MongoDB Search indexes
