mac.rst 5.1 KB

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