-
Notifications
You must be signed in to change notification settings - Fork 3
Docker mongodb image
nSoftteco edited this page Mar 5, 2016
·
1 revision
docker pull mongo:latest
docker run -v "$(pwd)":/data --name mongo -d mongo mongod --smallfiles
# display only running containers
docker ps
# or if you want all containers displayed
docker ps -a
docker run -it --link mongo:mongo --rm mongo sh -c 'exec mongo "$MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT/test"'
> show dbs
> exit
Personally, I like just connecting to a running container and executing needed commands from it. You can do what with:
docker exec -it 442c2541fe1a bash # by ID
# or
docker exec -it mongo bash # by Name
db.col.insert({"a": 4})
db.col.find().pretty()