Skip to content

Instantly share code, notes, and snippets.

@murarisumit
Last active April 20, 2018 09:16
Show Gist options
  • Save murarisumit/0a41f4a492c524d6015015ef297fc02e to your computer and use it in GitHub Desktop.
Save murarisumit/0a41f4a492c524d6015015ef297fc02e to your computer and use it in GitHub Desktop.
docker on mac #docker #docker-machine #virtualbox
  • On macOS the docker binary is only a client and you cannot use it to run the docker daemon, because Docker daemon uses Linux-specific kernel features, therefore you can’t run Docker natively in OS X.

  • So another tool was created, Docker-Machine, which creates a virtual machine (using yet another tool, e.g. Oracle VirtualBox), runs Docker on that VM, and helps coordinate between the host OS and the Docker VM.

  • Since Docker isn't running on your actual host OS, docker-machine needs to deal with IP addresses and ports and volumes and such. And its settings are saved in environment variables, which means you have to run commands like this every time you open a new shell.

  • To create a new docker machine : docker-machine create --driver virtualbox vm-name-here

  • To view environment variables to connect to new virtualbox vm : docker-machine env vm-name-here

  • To connect to docker via your shell, set environment variables by executing : eval $(docker-machine env vm-name-here).

  • Add eval $(docker-machine env vm-name-here) to bashrc, if you want to connect to connect set variable everytime your terminal starts.

  • Find running docker machine: docker-machine ls

  • Get status of of docker-machine: docker-machine status name

    • If not name is specified then default docker machine status is returned
  • Docker machine ssh (to virtualbox instance): docker-machine ssh docker-vm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment