docker run commands in mongo 1

docker run commands in mongo

sudo docker run -d -p 27017:27017 --name mongodb mongo:latest
sudo docker start mongodb
sudo docker exec -it mongodb mongo

Here is what the above code is Doing:
1. Pulling the latest MongoDB image from Docker Hub.
2. Running the MongoDB container in detached mode.
3. Exposing the container’s port 27017 to the host’s port 27017.
4. Naming the container as mongodb.
5. Starting the container.
6. Connecting to the container’s MongoDB shell.

Similar Posts