How to run a MongoDB Docker container with exposed port
docker run -d --name mongo-on-docker -p 27888:27017 -e MONGO_INITDB_ROOT_USERNAME=mongoadmin -e MONGO_INITDB_ROOT_PASSWORD=secret mongo
This command allows you to start a new MongoDB container with exposed port so that you could access the instance from the outside world.
Here is what the above code is doing:
1. Run a Docker container in the background and call it mongo-on-docker
2. Map the exposed port 27017 from the Docker container to port 27888 on the host
3. Set the environment variable MONGO_INITDB_ROOT_USERNAME to m