Docker 安裝 之 toolbox在Windows下安裝Docker)

TriHartmann 8年前發布 | 213K 次閱讀 Docker

來自: http://www.iganlei.cn/environment-configuration/798.html


安裝之前先了解下關鍵概念:

在linux上安裝Docker,你的機器即使localhost也是docker主機;在網絡中,localhost是指您的計算機。docker主機是容器中在該機器上運行。說白了就是直接安裝在linux上,英文翻譯真蛋疼。

在Windows安裝,Docker守護進程運行Linux虛擬機內。您可以使用Windows的客戶端與虛擬機中的Docker主機通信。這臺主機中運行你的Docker容器。

win_docker_host

 

在Windows中,Docker主機地址是Linux VM的地址。當啟動docker-machine虛擬機時會被分配一個IP地址。當你啟動一個容器,容器的端口會映射到VM。

安裝

 

https://www.docker.com/toolbox

或者去github上下在:https://github.com/boot2docker/windows-installer/releases

不能下載 可以到網盤下載 鏈接: http://pan.baidu.com/s/1jGrkJ7w 密碼: 3xie

blog20150921235847

基本是下一步,下一步,最后一步選上 加到path:

blog20150921235949

the Docker Quickstart Terminal

裝完后桌面上會多出幾個圖標,其中有一個是Docker Quickstart Terminal,雙擊運行,居然出現錯誤:

blog20150922001611

關掉,已管理員身份運行:
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/

host is not running
docker is configured to use the default machine with IP
For help getting started, check out the docs at https://docs.docker.com
lei@ganlei MINGW64 ~
$

手動啟動虛擬機,提示VT-x/AMD-V 硬件加速在系統中不可用;記得以前用VMware時開啟過的,重啟進BIOS檢查,發現狀態是Disabled,修改為Enabled 開啟虛擬化支持:

刪掉重新來:

Creating Machine default…
Creating VirtualBox VM…
Creating SSH key…
Starting VirtualBox VM…
Starting VM…
To see how to connect Docker to this machine, run: G:\Program Files\Docker Toolbox\docker-machine.exe env default
Starting machine default…
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.
Setting environment variables for machine default…
## .
## ## ## ==
## ## ## ## ## ===
/”””””””””””””””””\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ 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
lei@ganlei MINGW64 ~
$

瞅一眼Docker主機是什么樣子的:

blog20150922011047

通過運行hello-world容器來驗證是否安裝成功:

lei@ganlei MINGW64 ~
$ docker run hello-world
Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
535020c3e8ad: Pulling fs layer
af340544ed62: Pulling fs layer
af340544ed62: Verifying Checksum
af340544ed62: Download complete
535020c3e8ad: Verifying Checksum
535020c3e8ad: Download complete
535020c3e8ad: Pull complete
af340544ed62: Pull complete
library/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.
Digest: sha256:02fee8c3220ba806531f606525eceb83f4feb654f62b207191b1c9209188dedd
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.
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/
lei@ganlei MINGW64 ~
$

安裝Docker鏡像:

默認用戶名docker,密碼:tcuser

$ ssh docker@192.168.99.100
docker@192.168.99.100’s password:
## .
## ## ## ==
## ## ## ## ## ===
/”””””””””””””””””\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| ‘_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ ‘__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.8.2, build master : aba6192 – Thu Sep 10 20:58:17 UTC 2015
Docker version 1.8.2, build 0a8c2e3
docker@default:~$

拉取一個鏡像:
docker pull daocloud.io/daocloud/dao-2048:v1.0
Pulling repository daocloud.io/daocloud/dao-2048
ebedc5b763b3: Pulling image (v1.0) from daocloud.io/daocloud/dao-2048, endpoint:ebedc5b763b3: Download complete
31f630c65071: Download complete
1eae7e4d52e1: Download complete
63e8c6f236f9: Download complete
2a6e8fa08c63: Download complete
c96993b7308a: Download complete
Status: Downloaded newer image for daocloud.io/daocloud/dao-2048:v1.0

查看鏡像:
docker@default:~$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
hello-world latest af340544ed62 6 weeks ago 960 B
daocloud.io/daocloud/dao-2048 v1.0 ebedc5b763b3 9 weeks ago 8.017 MB
daocloud.io/library/ubuntu 10.04 3db9c44f4520 17 months ago 183 MB
docker@default:~$

運行容器:
docker@default:~$ docker run -i -t daocloud.io/library/ubuntu:10.04 /bin/bash
root@6c76a556b6ed:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root sbin selinux srv sys tmp usr var
root@6c76a556b6ed:/# pwd
/

blog20150922020318

 

如果有阿里云的ECS可以利用云服務器內網來拉取鏡像,阿里云ECS內網Docker鏡像地址:http://help.aliyun.com/knowledge_detail.htm?knowledgeId=5974865

docker官方安裝文檔:https://docs.docker.com/installation/windows/

 

 本文由用戶 TriHartmann 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!