2014-02-09 14:40:31 +02:00
|
|
|
|
:title: Installation on Mac OS X 10.6 Snow Leopard
|
2014-02-04 22:23:09 +02:00
|
|
|
|
:description: Please note this project is currently under heavy development. It should not be used in production.
|
|
|
|
|
:keywords: Docker, Docker documentation, requirements, virtualbox, ssh, linux, os x, osx, mac
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-04 14:16:27 -08:00
|
|
|
|
.. _macosx:
|
2013-08-27 14:29:49 -07:00
|
|
|
|
|
2014-02-04 14:16:27 -08:00
|
|
|
|
========
|
2014-02-04 22:23:09 +02:00
|
|
|
|
Mac OS X
|
|
|
|
|
========
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
.. note::
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
These instructions are available with the new release of Docker
|
|
|
|
|
(version 0.8). However, they are subject to change.
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2013-08-28 17:26:10 -07:00
|
|
|
|
.. include:: install_header.inc
|
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
Docker is supported on Mac OS X 10.6 "Snow Leopard" or newer.
|
2013-08-28 17:26:10 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
How To Install Docker On Mac OS X
|
|
|
|
|
=================================
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
VirtualBox
|
2013-04-22 18:38:42 -07:00
|
|
|
|
----------
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
Docker on OS X needs VirtualBox to run. To begin with, head over to
|
|
|
|
|
`VirtualBox Download Page`_ and get the tool for ``OS X hosts x86/amd64``.
|
|
|
|
|
|
|
|
|
|
.. _VirtualBox Download Page: https://www.virtualbox.org/wiki/Downloads
|
|
|
|
|
|
|
|
|
|
Once the download is complete, open the disk image, run the set up file
|
|
|
|
|
(i.e. ``VirtualBox.pkg``) and install VirtualBox. Do not simply copy the
|
|
|
|
|
package without running the installer.
|
|
|
|
|
|
|
|
|
|
boot2docker
|
|
|
|
|
-----------
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
`boot2docker`_ provides a handy script to easily manage the VM running the
|
|
|
|
|
``docker`` daemon. It also takes care of the installation for the OS image
|
|
|
|
|
that is used for the job.
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-19 11:35:58 +10:00
|
|
|
|
.. _GitHub page: https://github.com/boot2docker/boot2docker
|
2014-02-04 22:23:09 +02:00
|
|
|
|
|
2014-04-09 11:27:04 +02:00
|
|
|
|
With Homebrew
|
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
If you are using Homebrew on your machine, simply run the following command to install ``boot2docker``:
|
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
|
|
brew install boot2docker
|
|
|
|
|
|
|
|
|
|
Manual installation
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
Open up a new terminal window, if you have not already.
|
|
|
|
|
|
|
|
|
|
Run the following commands to get boot2docker:
|
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-05 00:29:07 +02:00
|
|
|
|
# Enter the installation directory
|
|
|
|
|
cd ~/bin
|
2014-02-09 05:05:19 -08:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
# Get the file
|
2014-02-19 11:35:58 +10:00
|
|
|
|
curl https://raw.github.com/boot2docker/boot2docker/master/boot2docker > boot2docker
|
2014-02-09 05:05:19 -08:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
# Mark it executable
|
|
|
|
|
chmod +x boot2docker
|
2013-09-04 17:47:18 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
Docker OS X Client
|
|
|
|
|
------------------
|
2013-09-04 17:47:18 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
The ``docker`` daemon is accessed using the ``docker`` client.
|
2013-09-04 17:47:18 -07:00
|
|
|
|
|
2014-04-09 11:27:04 +02:00
|
|
|
|
With Homebrew
|
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
Run the following command to install the ``docker`` client:
|
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
|
|
brew install docker
|
|
|
|
|
|
|
|
|
|
Manual installation
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
Run the following commands to get it downloaded and set up:
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
.. code-block:: bash
|
2013-04-23 12:04:53 -07:00
|
|
|
|
|
2014-03-19 14:12:47 +10:00
|
|
|
|
# Get the docker client file
|
2014-03-31 11:05:21 +10:00
|
|
|
|
DIR=$(mktemp -d ${TMPDIR:-/tmp}/dockerdl.XXXXXXX) && \
|
2014-03-19 14:12:47 +10:00
|
|
|
|
curl -f -o $DIR/ld.tgz https://get.docker.io/builds/Darwin/x86_64/docker-latest.tgz && \
|
|
|
|
|
gunzip $DIR/ld.tgz && \
|
|
|
|
|
tar xvf $DIR/ld.tar -C $DIR/ && \
|
|
|
|
|
cp $DIR/usr/local/bin/docker ./docker
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
# Set the environment variable for the docker daemon
|
2014-02-13 03:26:35 +02:00
|
|
|
|
export DOCKER_HOST=tcp://127.0.0.1:4243
|
2014-02-09 05:05:19 -08:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
# Copy the executable file
|
|
|
|
|
sudo cp docker /usr/local/bin/
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
And that’s it! Let’s check out how to use it.
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
How To Use Docker On Mac OS X
|
|
|
|
|
=============================
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
The ``docker`` daemon (via boot2docker)
|
|
|
|
|
---------------------------------------
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-05 00:29:07 +02:00
|
|
|
|
Inside the ``~/bin`` directory, run the following commands:
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
# Initiate the VM
|
|
|
|
|
./boot2docker init
|
|
|
|
|
|
|
|
|
|
# Run the VM (the docker daemon)
|
|
|
|
|
./boot2docker up
|
2014-02-09 05:05:19 -08:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
# To see all available commands:
|
|
|
|
|
./boot2docker
|
|
|
|
|
|
|
|
|
|
# Usage ./boot2docker {init|start|up|pause|stop|restart|status|info|delete|ssh|download}
|
|
|
|
|
|
|
|
|
|
The ``docker`` client
|
|
|
|
|
---------------------
|
2013-04-23 12:04:53 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
Once the VM with the ``docker`` daemon is up, you can use the ``docker``
|
|
|
|
|
client just like any other application.
|
2014-01-16 00:17:23 +00:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
|
|
docker version
|
|
|
|
|
# Client version: 0.7.6
|
|
|
|
|
# Go version (client): go1.2
|
|
|
|
|
# Git commit (client): bc3b2ec
|
|
|
|
|
# Server version: 0.7.5
|
|
|
|
|
# Git commit (server): c348c04
|
|
|
|
|
# Go version (server): go1.2
|
2014-01-16 00:17:23 +00:00
|
|
|
|
|
2014-02-09 05:05:19 -08:00
|
|
|
|
Forwarding VM Port Range to Host
|
2014-02-11 16:19:42 -08:00
|
|
|
|
--------------------------------
|
2014-02-09 05:05:19 -08:00
|
|
|
|
|
|
|
|
|
If we take the port range that docker uses by default with the -P option
|
|
|
|
|
(49000-49900), and forward same range from host to vm, we'll be able to interact
|
|
|
|
|
with our containers as if they were running locally:
|
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
|
|
# vm must be powered off
|
2014-02-19 10:50:11 +00:00
|
|
|
|
for i in {49000..49900}; do
|
2014-02-09 05:05:19 -08:00
|
|
|
|
VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i";
|
|
|
|
|
VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i";
|
|
|
|
|
done
|
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
SSH-ing The VM
|
|
|
|
|
--------------
|
2014-01-16 00:17:23 +00:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
If you feel the need to connect to the VM, you can simply run:
|
2014-01-16 00:17:23 +00:00
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
./boot2docker ssh
|
|
|
|
|
|
|
|
|
|
# User: docker
|
|
|
|
|
# Pwd: tcuser
|
|
|
|
|
|
|
|
|
|
You can now continue with the :ref:`hello_world` example.
|
2014-01-16 00:17:23 +00:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
Learn More
|
|
|
|
|
==========
|
2014-01-16 00:17:23 +00:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
boot2docker:
|
|
|
|
|
------------
|
2014-01-16 00:17:23 +00:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
See the GitHub page for `boot2docker`_.
|
2014-01-16 00:17:23 +00:00
|
|
|
|
|
2014-02-19 11:35:58 +10:00
|
|
|
|
.. _boot2docker: https://github.com/boot2docker/boot2docker
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
If SSH complains about keys:
|
|
|
|
|
----------------------------
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
ssh-keygen -R '[localhost]:2022'
|
2013-04-23 12:04:53 -07:00
|
|
|
|
|
2014-02-11 14:58:42 +10:00
|
|
|
|
Upgrading to a newer release of boot2docker
|
|
|
|
|
-------------------------------------------
|
|
|
|
|
|
|
|
|
|
To upgrade an initialised VM, you can use the following 3 commands. Your persistence
|
|
|
|
|
disk will not be changed, so you won't lose your images and containers:
|
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
|
|
./boot2docker stop
|
|
|
|
|
./boot2docker download
|
|
|
|
|
./boot2docker start
|
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
About the way Docker works on Mac OS X:
|
|
|
|
|
---------------------------------------
|
2013-04-19 20:57:50 -07:00
|
|
|
|
|
2014-02-04 22:23:09 +02:00
|
|
|
|
Docker has two key components: the ``docker`` daemon and the ``docker``
|
|
|
|
|
client. The tool works by client commanding the daemon. In order to
|
|
|
|
|
work and do its magic, the daemon makes use of some Linux Kernel
|
|
|
|
|
features (e.g. LXC, name spaces etc.), which are not supported by OS X.
|
|
|
|
|
Therefore, the solution of getting Docker to run on OS X consists of
|
|
|
|
|
running it inside a lightweight virtual machine. In order to simplify
|
|
|
|
|
things, Docker comes with a bash script to make this whole process as
|
|
|
|
|
easy as possible (i.e. boot2docker).
|