Install Docker on Mac OS X(转)
Install Docker on Mac OS X
You can install Docker using Boot2Docker to run docker commands at your command-line. Choose this installation if you are familiar with the command-line or plan to contribute to the Docker project on GitHub.

Alternatively, you may want to try Kitematic, an application that lets you set up Docker and run containers using a graphical user interface (GUI).
Command-line Docker with Boot2Docker
Because the Docker daemon uses Linux-specific kernel features, you can't run Docker natively in OS X. Instead, you must install the Boot2Docker application. The application includes a VirtualBox Virtual Machine (VM), Docker itself, and the Boot2Docker management tool.
The Boot2Docker management tool is a lightweight Linux virtual machine made specifically to run the Docker daemon on Mac OS X. The VirtualBox VM runs completely from RAM, is a small ~24MB download, and boots in approximately 5s.
Requirements
Your Mac must be running OS X 10.6 "Snow Leopard" or newer to run Boot2Docker.
Learn the key concepts before installing
In a Docker installation on Linux, your machine is both the localhost and the Docker host. In networking, localhost means your computer. The Docker host is the machine on which the containers run.
On a typical Linux installation, the Docker client, the Docker daemon, and any containers run directly on your localhost. This means you can address ports on a Docker container using standard localhost addressing such as localhost:8000 or 0.0.0.0:8376.

In an OS X installation, the docker daemon is running inside a Linux virtual machine provided by Boot2Docker.

In OS X, the Docker host address is the address of the Linux VM. When you start the boot2dockerprocess, the VM is assigned an IP address. Under boot2docker ports on a container map to ports on the VM. To see this in practice, work through the exercises on this page.
Install Boot2Docker
Go to the boot2docker/osx-installerrelease page.
Download Boot2Docker by clicking
Boot2Docker-x.x.x.pkgin the "Downloads" section.Install Boot2Docker by double-clicking the package.
The installer places Boot2Docker in your "Applications" folder.
The installation places the docker and boot2docker binaries in your /usr/local/bin directory.
Start the Boot2Docker Application
To run a Docker container, you first start the boot2docker VM and then issue docker commands to create, load, and manage containers. You can launch boot2docker from your Applications folder or from the command line.
NOTE: Boot2Docker is designed as a development tool. You should not use it in production environments.
From the Applications folder
When you launch the "Boot2Docker" application from your "Applications" folder, the application:
opens a terminal window
creates a $HOME/.boot2docker directory
creates a VirtualBox ISO and certs
starts a VirtualBox VM running the
dockerdaemon
Once the launch completes, you can run docker commands. A good way to verify your setup succeeded is to run the hello-world container.
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
511136ea3c5a: Pull complete
31cbccb51277: Pull complete
e45a5af57b00: Pull complete
hello-world:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Status: Downloaded newer image for hello-world:latest
Hello from Docker.
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(Assuming it was not already locally available.)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
For more examples and ideas, visit:
http://docs.docker.com/userguide/
A more typical way to start and stop boot2docker is using the command line.
From your command line
Initialize and run boot2docker from the command line, do the following:
Create a new Boot2Docker VM.
$ boot2docker initThis creates a new virtual machine. You only need to run this command once.
Start the
boot2dockerVM.$ boot2docker startDisplay the environment variables for the Docker client.
$ boot2docker shellinit Writing /Users/mary/.boot2docker/certs/boot2docker-vm/ca.pem Writing /Users/mary/.boot2docker/certs/boot2docker-vm/cert.pem Writing /Users/mary/.boot2docker/certs/boot2docker-vm/key.pem export DOCKER_HOST=tcp://192.168.59.103:2376 export DOCKER_CERT_PATH=/Users/mary/.boot2docker/certs/boot2docker-vm export DOCKER_TLS_VERIFY=1The specific paths and address on your machine will be different.
To set the environment variables in your shell do the following:
$ eval "$(boot2docker shellinit)"You can also set them manually by using the
exportcommandsboot2dockerreturns.Run the
hello-worldcontainer to verify your setup.$ docker run hello-world
Basic Boot2Docker Exercises
At this point, you should have boot2docker running and the docker client environment initialized. To verify this, run the following commands:
$ boot2docker status
$ docker version
Work through this section to try some practical container tasks using boot2docker VM.
Access container ports
Start an NGINX container on the DOCKER_HOST.
$ docker run -d -P --name web nginxNormally, the
docker runcommands starts a container, runs it, and then exits. The-dflag keeps the container running in the background after thedocker runcommand completes. The-Pflag publishes exposed ports from the container to your local host; this lets you access them from your Mac.Display your running container with
docker pscommandCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5fb65ff765e9 nginx:latest "nginx -g 'daemon of 3 minutes ago Up 3 minutes 0.0.0.0:49156->443/tcp, 0.0.0.0:49157->80/tcp webAt this point, you can see
nginxis running as a daemon.View just the container's ports.
$ docker port web 443/tcp -> 0.0.0.0:49156 80/tcp -> 0.0.0.0:49157This tells you that the
webcontainer's port80is mapped to port49157on your Docker host.Enter the
http://localhost:49157address (localhostis0.0.0.0) in your browser:
This didn't work. The reason it doesn't work is your
DOCKER_HOSTaddress is not the localhost address (0.0.0.0) but is instead the address of theboot2dockerVM.Get the address of the
boot2dockerVM.$ boot2docker ip 192.168.59.103Enter the
http://192.168.59.103:49157address in your browser:
Success!
To stop and then remove your running
nginxcontainer, do the following:$ docker stop web $ docker rm web
Mount a volume on the container
When you start boot2docker, it automatically shares your /Users directory with the VM. You can use this share point to mount directories onto your container. The next exercise demonstrates how to do this.
Change to your user
$HOMEdirectory.$ cd $HOMEMake a new
sitedirectory.$ mkdir siteChange into the
sitedirectory.$ cd siteCreate a new
index.htmlfile.$ echo "my new site" > index.htmlStart a new
nginxcontainer and replace thehtmlfolder with yoursitedirectory.$ docker run -d -P -v $HOME/site:/usr/share/nginx/html --name mysite nginxGet the
mysitecontainer's port.$ docker port mysite 80/tcp -> 0.0.0.0:49166 443/tcp -> 0.0.0.0:49165Open the site in a browser:

Try adding a page to your
$HOME/sitein real time.$ echo "This is cool" > cool.htmlOpen the new page in the browser.

Stop and then remove your running
mysitecontainer.$ docker stop mysite $ docker rm mysite
Upgrade Boot2Docker
If you running Boot2Docker 1.4.1 or greater, you can upgrade Boot2Docker from the command line. If you are running an older version, you should use the package provided by the boot2docker repository.
From the command line
To upgrade from 1.4.1 or greater, you can do this:
Open a terminal on your local machine.
Stop the
boot2dockerapplication.$ boot2docker stopRun the upgrade command.
$ boot2docker upgrade
Use the installer
To upgrade any version of Boot2Docker, do this:
Open a terminal on your local machine.
Stop the
boot2dockerapplication.$ boot2docker stopGo to the boot2docker/osx-installerrelease page.
Download Boot2Docker by clicking
Boot2Docker-x.x.x.pkgin the "Downloads" section.Install Boot2Docker by double-clicking the package.
The installer places Boot2Docker in your "Applications" folder.
Learning more and Acknowledgement
Use boot2docker help to list the full command line reference. For more information about using SSH or SCP to access the Boot2Docker VM, see the README at Boot2Docker repository.
Thanks to Chris Jones whose blog inspired me to redo this page.
Continue with the Docker User Guide.
参考:https://docs.docker.com/installation/mac/
http://dockerpool.com/static/books/docker_practice/appendix_command/README.html
Install Docker on Mac OS X(转)的更多相关文章
- Install wget in Mac OS X Without Homebrew or MacPorts
May 22, 2012 - 31 Comments The command line tool wget lets you retrieve a group of files from FTP an ...
- Install MySQL on Mac OS X——MAC安装MySQL
很多关于如何安装MySQL的教程已经过时了,或者比必须的步骤复杂得多.这篇教程将展示如何安装MySQL,启动MySQL,以root用户进入MySQL,以及创建删除退出数据库. Step 1: 下载My ...
- Mac OS X 软件推荐
1. 前言 每个操作系统都有自己的一套软件系统,但是不同的用户却会有不同的需求,系统虽会为用户提供一些基础软件,不过为了能无碍的进入自己的学习和工作状态,总有一些软件是必须安装的,同时这些软件也可以 ...
- Mac OS X 下安装使用 Docker
它依赖于 LXC(Linux Container),能从网络上获得配置好的 Linux 镜像,非常容易在隔离的系统中运行自己的应用.也因为它的底层核心是个 LXC,所以在 Mac OS X 下需要在 ...
- 在 Mac OS X 上安装 Docker(转)
http://www.oschina.net/translate/installing-docker-on-mac-os-x?print 在 Mac OS X 上安装 Docker 注意:Docker ...
- docker on Mac
贡献一篇: 云主机可以选择操作系统镜像快速创建主机,这比虚拟机更便捷了,我们本地也可以这么做了,因为有了 Docker 这个东西.它依赖于 LXC(Linux Container),能从网络上获得配置 ...
- 在 Mac OS 上创建并运行 ASP.NET Core 1.0 网站
var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...
- How To Fix – Mcrypt PHP extension required in Laravel on Mac OS X (No MAMP)
Laravel PHP web framework requires certain libraries to function properly. One of these libraries is ...
- [转]Debugging the Mac OS X kernel with VMware and GDB
Source: http://ho.ax/posts/2012/02/debugging-the-mac-os-x-kernel-with-vmware-and-gdb/ Source: http:/ ...
随机推荐
- [ruby on rails] 深入(1) ROR的一次request的响应过程
示意图 即: 1. 浏览器发起请求 2. Routes对请求进行一个url映射,交给对应的Controller来处理 3/4. Contoller从Model中获取数据(或者操作数据) 5. 返回给 ...
- linux系统vsftpd登陆慢卡怎么办
linux系统vsftpd登陆慢卡怎么办 浏览:145 | 更新:2013-12-31 00:50 vsftpd是linux系统中的一款ftp软件,用它可以实现文件,数据上传与下载,但有些用户会发现v ...
- mysql 日志文件mysql-bin文件清除方法,和mysql-bin相关文件的配置
默认情况下mysql会一直保留mysql-bin文件,这样到一定时候,磁盘可能会被撑满,这时候是否可以删除这些文件呢,是否可以安全删除,是个问题. 首先要说明一下,这些文件都是mysql的日志文件,如 ...
- 【Unity3D】使用鼠标键盘控制Camera视角(即时战略类游戏视角):缩近,拉远,旋转
今天写一个demo,要用到鼠标键盘控制三维视角,因此写了个脚本用于控制. 该脚本可以用于即时战略类游戏的视角,提供了缩进,拉伸,旋转.同时按住鼠标右键不放,移动鼠标可以实现第一人称视角的效果. usi ...
- ECharts分析xdebug跟踪日志
2015年12月23日 15:36:11 星期三 之前用的是国外的图表工具, 有点麻烦, 文档是英文的, 看着不顺眼, 发现了百度出品的ECharts, 文档比较全, 功能比较多, 做出的图也比较好看 ...
- java web 学习 --第二天(Java三级考试)
第一天的学习在这http://www.cnblogs.com/tobecrazy/p/3444474.html 2.jsp 基础知识 Jsp页面中的Java脚本主要有3部分:声明(Declaratio ...
- Java for LeetCode 224 Basic Calculator
Implement a basic calculator to evaluate a simple expression string. The expression string may conta ...
- ASM:《X86汇编语言-从实模式到保护模式》1-4章:处理器,内存和硬盘基础
其实很久之前就学完了实模式了,但是一直没有总结,感觉现在直接在书上做笔记的弊端就是有些知识点不能很很深刻地记下来(毕竟手写最明显的优点就是能深刻地记住知识,但是就是用太多的时间罢了).一下内容都是一些 ...
- LeetCode 409 Longest Palindrome
Problem: Given a string which consists of lowercase or uppercase letters, find the length of the lon ...
- ASIHTTPRequest详解 [经典]
ASIHTTPRequest 对CFNetwork API进行了封装,并且使用起来非常简单,用Objective-C编写,可以很好的应用在Mac OS X系统和iOS平台的应用程序中.ASIHTTPR ...