To get started with a MongoDB Docker container, run the docker run towards MongoDB. Here is an example
sudo docker run --name codetryout-mongo -d mongo
- sudo – if you are using a non-root user (which is recommended)
- the docker run command
- –name followed by your preferred name label for the container
- Finally the image name -d mongo
Demo – docker runs MongoDB container
How to verify whether your docker MongoDB container is running?
Here is the command to check the container status
sudo docker ps
Typical output:
dev@codetryout:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ffc3701f3a5a mongo "docker-entrypoint.s…" 10 minutes ago Up 10 minutes 27017/tcp codetryout-mongo
References:
- Read more about MongoDB:- https://en.wikipedia.org/wiki/MongoDB
- Docker image from DockerHub: https://hub.docker.com/_/mongo