docker系列2: windows安装docker

1,使用DockerToolbox.exe安装

下载安装包: https://docs.docker.com/docker-for-windows/
安装完成后桌面会生成三个快捷方式,分别为:
(1) Docker Quickstart Terminal: 提供Docker的命令行操作
(2) Oracle VM VirtualBox: 虚拟机软件。
(3) Kitematic (Alpha):图形化的docker工具

点击Docker Quickstart Terminal快捷方式,开始配置docker在virtualbox的镜像

(镜像boot2docker.iso在virtualbox上安装和启动 -----> ip分配 ----> 文件拷贝到本地)
可能出现以下错误:

unable to get the local Boot2Docker ISO version:Did not find prefix "-v" in version string ,start download .....
====频繁出现这种提示: 查看当前用户路径下 C:\Users\用户名xx\.docker\machine\machines\
是否已经存在default这个目录, 若存在则删除,等待安装成功的docker鲸鱼logo出现

2, 使用docker-machine.exe 命令行安装

下载所需的原始镜像 boot2docker.iso:https://github.com/boot2docker/boot2docker/releases

(镜像boot2docker.iso在virtualbox上安装和启动 -----> ip分配 ----> 文件拷贝到本地)

  • 1, docker-machine.exe create --driver virtualbox --virtualbox-boot2docker-url=boot2docker.iso存放路径 生成的docker镜像名称
  • 2, docker-machine.exe env docker
  • 3, docker-machine.exe env docker |Invoke-Expression
1, 使用iso文件: 创建virtualbox 虚拟机
# docker-machine.exe create --engine-registry-mirror=https://XXXXXX(换上你的阿里云专属镜像).mirror.aliyuncs.com  --driver virtualbox --virtualbox-boot2docker-url=boot2docker.iso docker1
PS C:\Users\jibin\.docker\machine> docker-machine.exe create --driver virtualbox --virtualbox-boot2docker-url=boot2docker.iso存放路径  生成的docker镜像名称

Running pre-create checks...
(docker) Boot2Docker URL was explicitly set to ".\\cache\\boot2docker.iso" at create time, so Docker Machine cannot upgr
ade this machine to the latest version.
Creating machine...
(docker) Boot2Docker URL was explicitly set to ".\\cache\\boot2docker.iso" at create time, so Docker Machine cannot upgr
ade this machine to the latest version.
(docker) Downloading C:\Users\jibin\.docker\machine\cache\boot2docker.iso from .\cache\boot2docker.iso...
(docker) Creating VirtualBox VM...
(docker) Creating SSH key...
(docker) Starting the VM...
(docker) Check network to re-create if needed...
(docker) Windows might ask for the permission to create a network adapter. Sometimes, such confirmation window is minimi
zed in the taskbar.
(docker) Found a new host-only adapter: "VirtualBox Host-Only Ethernet Adapter #2"
(docker) Windows might ask for the permission to configure a network adapter. Sometimes, such confirmation window is min
imized in the taskbar.
(docker) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation window is minimiz
ed in the taskbar.
(docker) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: F:\docker\Docker Too
lbox\docker-machine.exe env docker
PS C:\Users\jibin\.docker\machine> docker ps
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.37/containers/json: open //./pipe/docker_engine: The
system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run ele
vated to connect. This error may also indicate that the docker daemon is not running.

2, 配置docker环境
vated to connect. This error may also indicate that the docker daemon is not running.
PS C:\Users\jibin\.docker\machine> docker-machine.exe env docker
$Env:DOCKER_TLS_VERIFY = "1"
$Env:DOCKER_HOST = "tcp://192.168.99.100:2376"
$Env:DOCKER_CERT_PATH = "C:\Users\jibin\.docker\machine\machines\docker"
$Env:DOCKER_MACHINE_NAME = "docker"
$Env:COMPOSE_CONVERT_WINDOWS_PATHS = "true"
# Run this command to configure your shell:
# & "F:\docker\Docker Toolbox\docker-machine.exe" env docker | Invoke-Expression

PS C:\Users\jibin\.docker\machine> docker-machine.exe env docker |Invoke-Expression
Run 'docker COMMAND --help' for more information on a command.
PS C:\Users\jibin\.docker\machine> docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

3, 配置阿里镜像加速

找到docker容器的配置文件: 如default容器
C:\Users\用户名xx.docker\machine\machines\default\config.json

C:\Users\用户xxx\.docker\machine\machines\docker0\config.json
"ConfigVersion": 3,
    "Driver": {
        "IPAddress": "192.168.99.100",
        "MachineName": "docker0",
        "SSHUser": "docker",
        "SSHPort": 61640,

找出该虚拟机的ip, 使用ssh工具连接[ 用户名: docker , 密码:tcuser ],输入命令如下:

sudo tee /etc/docker/daemon.json <<EOF
{
  "registry-mirrors": ["https://yywkvob3.mirror.aliyuncs.com"]
}
EOF

回到windows powershell:

docker-machine.exe restart default
docker-machine.exe env docker
docker-machine.exe env docker |Invoke-Expression
#验证是否ok: 查看末尾是否有一条阿里云的registry网址
docker info 

猜你喜欢

转载自blog.csdn.net/eyeofeagle/article/details/85387108