Created
February 14, 2020 23:05
-
-
Save agu3rra/f6347cb45941a0d736dfb13fd49d16fb to your computer and use it in GitHub Desktop.
Docker commands for playing with MongoDB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run a container and expose port to host | |
docker run --name mongo-instance-01 -p 27017:27017 -d mongo:latest | |
# Access its terminal | |
docker ps | |
docker exec -it <container-id> bash | |
# Run the same mongo DB in the above example with persistence. | |
docker volume create mongo-volume-01 | |
docker run \ | |
--name mongo-instance-01 \ | |
-p 27017:27017 \ | |
--mount 'type=volume,src=mongo-volume-01,dst=/data/db/' \ | |
-d mongo:latest \ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment