mac.rst 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. With Homebrew
  30. ~~~~~~~~~~~~~
  31. If you are using Homebrew on your machine, simply run the following command to install ``boot2docker``:
  32. .. code-block:: bash
  33. brew install boot2docker
  34. Manual installation
  35. ~~~~~~~~~~~~~~~~~~~
  36. Open up a new terminal window, if you have not already.
  37. Run the following commands to get boot2docker:
  38. .. code-block:: bash
  39. # Enter the installation directory
  40. cd ~/bin
  41. # Get the file
  42. curl https://raw.github.com/boot2docker/boot2docker/master/boot2docker > boot2docker
  43. # Mark it executable
  44. chmod +x boot2docker
  45. Docker OS X Client
  46. ------------------
  47. The ``docker`` daemon is accessed using the ``docker`` client.
  48. With Homebrew
  49. ~~~~~~~~~~~~~
  50. Run the following command to install the ``docker`` client:
  51. .. code-block:: bash
  52. brew install docker
  53. Manual installation
  54. ~~~~~~~~~~~~~~~~~~~
  55. Run the following commands to get it downloaded and set up:
  56. .. code-block:: bash
  57. # Get the docker client file
  58. DIR=$(mktemp -d ${TMPDIR:-/tmp}/dockerdl.XXXXXXX) && \
  59. curl -f -o $DIR/ld.tgz https://get.docker.io/builds/Darwin/x86_64/docker-latest.tgz && \
  60. gunzip $DIR/ld.tgz && \
  61. tar xvf $DIR/ld.tar -C $DIR/ && \
  62. cp $DIR/usr/local/bin/docker ./docker
  63. # Set the environment variable for the docker daemon
  64. export DOCKER_HOST=tcp://127.0.0.1:4243
  65. # Copy the executable file
  66. sudo cp docker /usr/local/bin/
  67. And that’s it! Let’s check out how to use it.
  68. How To Use Docker On Mac OS X
  69. =============================
  70. The ``docker`` daemon (via boot2docker)
  71. ---------------------------------------
  72. Inside the ``~/bin`` directory, run the following commands:
  73. .. code-block:: bash
  74. # Initiate the VM
  75. ./boot2docker init
  76. # Run the VM (the docker daemon)
  77. ./boot2docker up
  78. # To see all available commands:
  79. ./boot2docker
  80. # Usage ./boot2docker {init|start|up|pause|stop|restart|status|info|delete|ssh|download}
  81. The ``docker`` client
  82. ---------------------
  83. Once the VM with the ``docker`` daemon is up, you can use the ``docker``
  84. client just like any other application.
  85. .. code-block:: bash
  86. docker version
  87. # Client version: 0.7.6
  88. # Go version (client): go1.2
  89. # Git commit (client): bc3b2ec
  90. # Server version: 0.7.5
  91. # Git commit (server): c348c04
  92. # Go version (server): go1.2
  93. Forwarding VM Port Range to Host
  94. --------------------------------
  95. If we take the port range that docker uses by default with the -P option
  96. (49000-49900), and forward same range from host to vm, we'll be able to interact
  97. with our containers as if they were running locally:
  98. .. code-block:: bash
  99. # vm must be powered off
  100. for i in {49000..49900}; do
  101. VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i";
  102. VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i";
  103. done
  104. SSH-ing The VM
  105. --------------
  106. If you feel the need to connect to the VM, you can simply run:
  107. .. code-block:: bash
  108. ./boot2docker ssh
  109. # User: docker
  110. # Pwd: tcuser
  111. You can now continue with the :ref:`hello_world` example.
  112. Learn More
  113. ==========
  114. boot2docker:
  115. ------------
  116. See the GitHub page for `boot2docker`_.
  117. .. _boot2docker: https://github.com/boot2docker/boot2docker
  118. If SSH complains about keys:
  119. ----------------------------
  120. .. code-block:: bash
  121. ssh-keygen -R '[localhost]:2022'
  122. Upgrading to a newer release of boot2docker
  123. -------------------------------------------
  124. To upgrade an initialised VM, you can use the following 3 commands. Your persistence
  125. disk will not be changed, so you won't lose your images and containers:
  126. .. code-block:: bash
  127. ./boot2docker stop
  128. ./boot2docker download
  129. ./boot2docker start
  130. About the way Docker works on Mac OS X:
  131. ---------------------------------------
  132. Docker has two key components: the ``docker`` daemon and the ``docker``
  133. client. The tool works by client commanding the daemon. In order to
  134. work and do its magic, the daemon makes use of some Linux Kernel
  135. features (e.g. LXC, name spaces etc.), which are not supported by OS X.
  136. Therefore, the solution of getting Docker to run on OS X consists of
  137. running it inside a lightweight virtual machine. In order to simplify
  138. things, Docker comes with a bash script to make this whole process as
  139. easy as possible (i.e. boot2docker).