mac.rst 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. :title: Installation on Mac OS X 10.6 Snow Leopard
  2. :description: Please note this project is currently under heavy development. It should not be used in production.
  3. :keywords: Docker, Docker documentation, requirements, virtualbox, ssh, linux, os x, osx, mac
  4. .. _macosx:
  5. ========
  6. Mac OS X
  7. ========
  8. .. note::
  9. These instructions are available with the new release of Docker
  10. (version 0.8). However, they are subject to change.
  11. .. include:: install_header.inc
  12. Docker is supported on Mac OS X 10.6 "Snow Leopard" or newer.
  13. How To Install Docker On Mac OS X
  14. =================================
  15. VirtualBox
  16. ----------
  17. Docker on OS X needs VirtualBox to run. To begin with, head over to
  18. `VirtualBox Download Page`_ and get the tool for ``OS X hosts x86/amd64``.
  19. .. _VirtualBox Download Page: https://www.virtualbox.org/wiki/Downloads
  20. Once the download is complete, open the disk image, run the set up file
  21. (i.e. ``VirtualBox.pkg``) and install VirtualBox. Do not simply copy the
  22. package without running the installer.
  23. boot2docker
  24. -----------
  25. `boot2docker`_ provides a handy script to easily manage the VM running the
  26. ``docker`` daemon. It also takes care of the installation for the OS image
  27. that is used for the job.
  28. .. _GitHub page: https://github.com/boot2docker/boot2docker
  29. Open up a new terminal window, if you have not already.
  30. Run the following commands to get boot2docker:
  31. .. code-block:: bash
  32. # Enter the installation directory
  33. cd ~/bin
  34. # Get the file
  35. curl https://raw.github.com/boot2docker/boot2docker/master/boot2docker > boot2docker
  36. # Mark it executable
  37. chmod +x boot2docker
  38. Docker OS X Client
  39. ------------------
  40. The ``docker`` daemon is accessed using the ``docker`` client.
  41. Run the following commands to get it downloaded and set up:
  42. .. code-block:: bash
  43. # Get the file
  44. curl -o docker https://get.docker.io/builds/Darwin/x86_64/docker-latest
  45. # Mark it executable
  46. chmod +x docker
  47. # Set the environment variable for the docker daemon
  48. export DOCKER_HOST=tcp://127.0.0.1:4243
  49. # Copy the executable file
  50. sudo cp docker /usr/local/bin/
  51. And that’s it! Let’s check out how to use it.
  52. How To Use Docker On Mac OS X
  53. =============================
  54. The ``docker`` daemon (via boot2docker)
  55. ---------------------------------------
  56. Inside the ``~/bin`` directory, run the following commands:
  57. .. code-block:: bash
  58. # Initiate the VM
  59. ./boot2docker init
  60. # Run the VM (the docker daemon)
  61. ./boot2docker up
  62. # To see all available commands:
  63. ./boot2docker
  64. # Usage ./boot2docker {init|start|up|pause|stop|restart|status|info|delete|ssh|download}
  65. The ``docker`` client
  66. ---------------------
  67. Once the VM with the ``docker`` daemon is up, you can use the ``docker``
  68. client just like any other application.
  69. .. code-block:: bash
  70. docker version
  71. # Client version: 0.7.6
  72. # Go version (client): go1.2
  73. # Git commit (client): bc3b2ec
  74. # Server version: 0.7.5
  75. # Git commit (server): c348c04
  76. # Go version (server): go1.2
  77. Forwarding VM Port Range to Host
  78. --------------------------------
  79. If we take the port range that docker uses by default with the -P option
  80. (49000-49900), and forward same range from host to vm, we'll be able to interact
  81. with our containers as if they were running locally:
  82. .. code-block:: bash
  83. # vm must be powered off
  84. for i in {4900..49900}; do
  85. VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i";
  86. VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i";
  87. done
  88. SSH-ing The VM
  89. --------------
  90. If you feel the need to connect to the VM, you can simply run:
  91. .. code-block:: bash
  92. ./boot2docker ssh
  93. # User: docker
  94. # Pwd: tcuser
  95. You can now continue with the :ref:`hello_world` example.
  96. Learn More
  97. ==========
  98. boot2docker:
  99. ------------
  100. See the GitHub page for `boot2docker`_.
  101. .. _boot2docker: https://github.com/boot2docker/boot2docker
  102. If SSH complains about keys:
  103. ----------------------------
  104. .. code-block:: bash
  105. ssh-keygen -R '[localhost]:2022'
  106. Upgrading to a newer release of boot2docker
  107. -------------------------------------------
  108. To upgrade an initialised VM, you can use the following 3 commands. Your persistence
  109. disk will not be changed, so you won't lose your images and containers:
  110. .. code-block:: bash
  111. ./boot2docker stop
  112. ./boot2docker download
  113. ./boot2docker start
  114. About the way Docker works on Mac OS X:
  115. ---------------------------------------
  116. Docker has two key components: the ``docker`` daemon and the ``docker``
  117. client. The tool works by client commanding the daemon. In order to
  118. work and do its magic, the daemon makes use of some Linux Kernel
  119. features (e.g. LXC, name spaces etc.), which are not supported by OS X.
  120. Therefore, the solution of getting Docker to run on OS X consists of
  121. running it inside a lightweight virtual machine. In order to simplify
  122. things, Docker comes with a bash script to make this whole process as
  123. easy as possible (i.e. boot2docker).