Docker and MongoDB
FAQ
If you need to run MongoDB on-premises, running it in a Docker container is a convenient way to run and manage your instances. To do so, you should use our MongoDB Enterprise images. If you want to use MongoDB in your development environment, you can use the community version managed by MongoDB or use MongoDB Atlas to access all the features of MongoDB.
Just as you would with any other application, you can connect to MongoDB using a connection string. To pass this connection string to your containerized application, you can use the `-e` parameter with the Docker CLI tool. Your application will read this connection string as an environment variable and use it to connect to your MongoDB instance.
You can start a MongoDB container just like any other container. If port 27017 is exposed to the host, you will be able to connect to your MongoDB Docker container using the connection string mongodb://HOST:PORT.