Docker引擎是基於Linux內核特性的開源應用容器。讓開發者能夠打包他們的應用以及依賴包到一個可移植的容器中,發佈到任何流行的Linux容器上,實現虛擬化,容器運行在相似與iphone的沙盒中。
在MacOs上面運行Docker先安裝Docker Toolbox
。面試
Docker Toolbox是獲取以及運行Docker生產環境最快捷的方式,他包括:docker
1.Docker Machine 2.Docker 3.docker-compose 4.Docker GUI 5.Docker command-line 6.VirtualBox
由於Docker是以及Linux內核的,因此不能直接在OS X上面運行,所以咱們須要VirtualBox,由於一個虛擬的Docker環境。
環境要求:OS X 10.8以上的,才能安裝運行Docker Toolbox
。shell
下載地址:https://www.docker.com/products/docker-toolbox
下載以後雙擊安裝文件開始安裝。ubuntu
安裝界面:
點擊Continue
能夠看到要安裝的工具:
bash
默認狀況下Docker Toolbox會安裝在/usr/local/bin目錄下面。咱們須要讓全部的用戶都有訪問Docker Toolbox
安裝文件的權限。
會出現讓咱們輸入密碼的界面:
app
最後會安裝兩個快速啓動的工具:
iphone
雙擊Application的Docker Quickstart Terminal
:
選擇一個經常使用的終端,我選擇的是iTerm。
等待初始化完成以後出現下面的界面ide
## . ## ## ## == ## ## ## ## ## === /"""""""""""""""""\___/ === ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~ \______ o __/ \ \ __/ \____\_______/ docker is configured to use the default machine with IP 192.168.99.100 For help getting started, check out the docs at https://docs.docker.com Welcome to fish, the friendly interactive shell Type help for instructions on how to use fish
Docker的初始化運行已經完成了,下面試試經典的hello world
。工具
運行命令:ui
docker run hello-world
獲得一個錯誤信息:
docker: Error response from daemon: client is newer than server (client API version: 1.22, server API version: 1.21). See 'docker run --help'.
明顯的 docker server的版本太低,升級下 docker server
docker-machine upgrade
再次運行:
docker run hello-world
獲得結果:
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. 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 Share images, automate workflows, and more with a free Docker Hub account: https://hub.docker.com For more examples and ideas, visit: https://docs.docker.com/userguide/
安裝Docker完成。