install mongo
1 | sudo docker search mongo |
show images list
1 | sudo docker images |
1 | REPOSITORY TAG IMAGE ID CREATED SIZE |
run mongo
1 | docker run --name some-mongo -p 27017:27017 -d mongo:3.2 |
1 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
how to verify mongo running
open http://localhost:27017/, will show
It looks like you are trying to access MongoDB over HTTP on the native driver port.
using docker container bash
1 | sudo docker exec -it <container_ID> sh |
backup mongo
1 | sudo docker cp <container_ID>:/data/db ./20170101 |
stop container
1 | sudo docker stop <ocntainer_ID> |
some useful cmd
1 | sudo docker container ls -a // list all container, include stopped |
docker cp
docker cp mycontainer:/opt/testnew/file.txt /opt/test/
docker cp /opt/test/file.txt mycontainer:/opt/testnew/
sudo docker cp /home/liuli/backup/dump/* cn-prod:/dump
sudo docker cp 2a1296fae066:/data/db /home/ubuntu/mongo-backup/04-23-2018-empty
sudo docker cp /home/ubuntu/mongo-backup/12-21-2017/* 2a1296fae066:/data/db