Skip to content

Instantly share code, notes, and snippets.

@nsabharwal
Last active April 7, 2016 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nsabharwal/e987cb0d0e02f7bf2bf815615a01d8d4 to your computer and use it in GitHub Desktop.
Save nsabharwal/e987cb0d0e02f7bf2bf815615a01d8d4 to your computer and use it in GitHub Desktop.
##Create the vm
boot2docker init -m 8192 -s 30000 ( memory and size in GB)
###Start the vm
boot2docker up
# Set the variables
`eval "$(boot2docker shellinit)"`
## Find the IP
boot2docker IP
##ssh into docker vm
boot2docker ssh
#Detach from the container
ctrl-p ctrl-q or try ctrl p q
##################
#kill all the containers
alias docker-kill-all='docker rm -f $(docker ps -qa)'
docker-kill-all
# running containers
docker ps
# run a container with name web and have nginx running in detached mode and pay attention to -p 8080:80
# you will need output from boot2docker ip and then use that ip:8080 to access the nginx from your mac
docker run -d -p 8080:80 --name web nginx
docker exec -it web bash
echo myself for president > /usr/share/nginx/html/index.html
# find the IP of container
docker inspect web | grep IP
docker inspect -f '{{json .NetworkSettings.IPAddress}}' container
# login to the container
docker exec -it web bash
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment