2014-12-06 wcdj
摘要:本文记录Docker在OS X Yosemite的安装方法,也可参考Docker的这篇文章Installing Docker on Mac OS X。
0 介绍
Docker is a platform for developers and sysadmins to develop, ship, and run applications. Docker lets you quickly assemble applications from components and eliminates the friction that can come when shipping code. Docker lets you get your code tested and deployed into productionas fast as possible.
Docker consists of:
- The Docker Engine - our lightweight and powerful open source container virtualization technology combined with a work flow for building and containerizing your applications.
- Docker Hub - our SaaS service for sharing and managing your application stacks.
1 安装
下载最新的安装包:Boot2Docker-1.3.2.pkg,安装完成后如下图所示:
docker的默认安装目录:
docker的相关用法:
gerryyang@mba:docker$docker
Usage: docker [OPTIONS] COMMAND [arg...]
A self-sufficient runtime for linux containers.
Options:
--api-enable-cors=false Enable CORS headers in the remote API
-D, --debug=false Enable debug mode
-d, --daemon=false Enable daemon mode
-G, --group="docker" Group to assign the unix socket specified by -H when running in daemon mode
use '' (the empty string) to disable setting of a group
-H, --host=[] The socket(s) to bind to in daemon mode or connect to in client mode, specified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd.
--tls=false Use TLS; implied by tls-verify flags
--tlscacert="/Users/gerryyang/.docker/ca.pem" Trust only remotes providing a certificate signed by the CA given here
--tlscert="/Users/gerryyang/.docker/cert.pem" Path to TLS certificate file
--tlskey="/Users/gerryyang/.docker/key.pem" Path to TLS key file
--tlsverify=false Use TLS and verify the remote (daemon: verify client, client: verify daemon)
-v, --version=false Print version information and quit
Commands:
attach Attach to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders from a container's filesystem to the host path
create Create a new container
diff Inspect changes on a container's filesystem
events Get real time events from the server
exec Run a command in an existing container
export Stream the contents of a container as a tar archive
history Show the history of an image
images List images
import Create a new filesystem image from the contents of a tarball
info Display system-wide information
inspect Return low-level information on a container
kill Kill a running container
load Load an image from a tar archive
login Register or log in to a Docker registry server
logout Log out from a Docker registry server
logs Fetch the logs of a container
port Lookup the public-facing port that is NAT-ed to PRIVATE_PORT
pause Pause all processes within a container
ps List containers
pull Pull an image or a repository from a Docker registry server
push Push an image or a repository to a Docker registry server
restart Restart a running container
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save an image to a tar archive
search Search for an image on the Docker Hub
start Start a stopped container
stop Stop a running container
tag Tag an image into a repository
top Lookup the running processes of a container
unpause Unpause a paused container
version Show the Docker version information
wait Block until a container stops, then print its exit code
Run 'docker COMMAND --help' for more information on a command.
gerryyang@mba:~$boot2docker
Usage: boot2docker [<options>] {help|init|up|ssh|save|down|poweroff|reset|restart|config|status|info|ip|shellinit|delete|download|upgrade|version} [<args>]
gerryyang@mba:~$boot2docker init
Latest release for boot2docker/boot2docker is v1.3.2
Downloading boot2docker ISO image...
Success: downloaded https://github.com/boot2docker/boot2docker/releases/download/v1.3.2/boot2docker.iso
to /Users/gerryyang/.boot2docker/boot2docker.iso
Generating public/private rsa key pair.
Your identification has been saved in /Users/gerryyang/.ssh/id_boot2docker.
Your public key has been saved in /Users/gerryyang/.ssh/id_boot2docker.pub.
The key fingerprint is:
3f:1d:a1:10:0e:db:68:1a:d1:8d:07:bd:c1:30:9d:f1 gerryyang@mba.local
The key's randomart image is:
+--[ RSA 2048]----+
| ..=Ooo |
| .oBOo |
| . +.+oE . |
| + .. . . |
| . S . . |
| . . . |
| o . |
| . |
| |
+-----------------+
gerryyang@mba:~$boot2docker start
Waiting for VM and Docker daemon to start...
.........................oooooooooooooooooooooooo
Started.
Writing /Users/gerryyang/.boot2docker/certs/boot2docker-vm/ca.pem
Writing /Users/gerryyang/.boot2docker/certs/boot2docker-vm/cert.pem
Writing /Users/gerryyang/.boot2docker/certs/boot2docker-vm/key.pem
To connect the Docker client to the Docker daemon, please set:
export DOCKER_HOST=tcp://192.168.59.103:2376
export DOCKER_CERT_PATH=/Users/gerryyang/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1
gerryyang@mba:~$docker run hello-world
Unable to find image 'hello-world' locally
hello-world:latest: The image you are pulling has been verified
511136ea3c5a: Pull compl