1. Firstly, pull the initial Docker image of MongoDB from the docker hub by running the below command in your terminal:
```
docker pull mongo
```
1. After downloading it, create a new container instance by running this command:
```
docker run -d -p 27017-27019:27017-27019 —name mongodb mongo
```
Here ‘-d’ detach run the MongoDB instance in the background, ‘-p’ publish mongo’s ports inside the docker machine to the host, ‘—name mongodb’ name the instance as “mongodb”
1. You can connect to this MongoDB instance using your local MongoDB client through localhost and the default port (27017) or any Docker Machine IP.
1. If you want to run mongo shell inside the docker container, you can type:
```
docker exec -it mongodb bash
```
1. You’re now in the docker container’s bash. To connect to the mongo instance, just type:
```
mongo
```
Now you are ready to perform operations on MongoDB such as creating, retrieving, updating, and deleting data etc.
1. If you want to add a database user, while inside the mongo shell in your Docker container, use commands similar to this:
```
use
db.createUser(
{
user: “youruser”,
pwd: “yourpassword”,
roles: [ { role: “dbOwner”, db: “test” } ]
}
)
```
Replace “
1. Once finished, you can stop the Docker container by running:
```
docker stop mongodb
```
Additionally, it’s good practice to use an official Docker image for MongoDB in production-like settings and handle data persistence separately.