Skip to content

Instantly share code, notes, and snippets.

@johnykov
Created May 21, 2014 11:44
Show Gist options
  • Save johnykov/bfc7825d54a5294d394e to your computer and use it in GitHub Desktop.
Save johnykov/bfc7825d54a5294d394e to your computer and use it in GitHub Desktop.
Step-by-step mongo in docker on macosx
1.
brew install boot2docker
brew install docker
echo "export DOCKER_HOST=tcp://127.0.0.1:4243" >>~/.bash_profile
2.
boot2docker init #once init virtualbox vm
VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$27017,tcp,,27017,,27017";
3.
boot2docker up
docker pull dockerfile/mongodb #pulling image once
4.
docker run -d -p 27017:27017 --name mongodb dockerfile/mongodb #set name once
# do magic here, use client mongo shell on your host i.e.
mongo
use jan
db.foo.save({"wat":"a start"})
5.
docker stop mongodb
boot2docker stop
6.
boot2docker start
docker start mongodb
# do magic here, use client mongo shell on your host i.e.
mongo
use jan
db.foo.find()
# assert obj in collection
7.
docker stop mongodb
boot2docker stop
#useful commands:
# docker ps -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment