美文网首页
Docker windows安装并启用镜像加速

Docker windows安装并启用镜像加速

作者: 凌雲木 | 来源:发表于2018-12-21 01:51 被阅读105次

Docker在windows10上的使用

安装环境:Win10专业版
电脑启用虚拟化
启动Hyper-V虚拟机

1.启用Hyper-V

控制面板—程序和功能—启用或关闭Windows功能—勾选Hyper-V


启用Hyper-V

2安装Docker

.Docker官网下载地址为:https://store.docker.com/editions/community/docker-ce-desktop-windows

下载Docker

下载后一直Next安装,安装成功后会出现Docker类型小鱼的图标,说明安装完成了


安装完成

3启动Docker运行hello-world

PS C:\WINDOWS\system32> docker -v
Docker version 18.09.0, build 4d60db4
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32>  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.
    (amd64)
 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 ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

docker run hello-world运行成功,说明docker在windows上已经正确安装

4 Docker启用镜像加速

Docker的镜像从Docker Hub下载,鉴于国内的网速在国内使用Docker Hub的话就特别慢,为此,我们可以给Docker配置国内的加速地址。阿里云镜像就是一个不错的选择。
我们登陆阿里云官网,在产品服务里找到容器服务,点击立即开通,开通成功后进入管理控制台


阿里云镜像
获取阿里云加速镜像地址

把阿里云加速镜像地址配置到Docker设置中,就可以使用镜像加速
在安装成功后Docker小鱼的图标右键,找到Settings进去



进入daemon菜单,把阿里云分配的加速地址,复制进registy,上面哪个属于私有仓库配置,不用管,然后点击应用
image.png
复制完阿里云镜像加速地址,点击Apply,Docker会自动重启。
第二种简单设置Docker镜像加速可以在Docker配置文件直接修改镜像地址:
Docker配置文件

配置文件路径:C:\Users\用户名.docker\daemon.json

Docker的镜像默认都在C盘保存,可以修改保存路径


设置Docker镜像的保存路径

设置完Docker会自动重启


Docker自动重启成功

可以通过docker search 命令查找镜像

PS C:\WINDOWS\system32> docker search ubuntu
NAME                                                   DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
ubuntu                                                 Ubuntu is a Debian-based Linux operating sys…   8994                [OK]
dorowu/ubuntu-desktop-lxde-vnc                         Ubuntu with openssh-server and NoVNC            258                                     [OK]
rastasheep/ubuntu-sshd                                 Dockerized SSH service, built on top of offi…   190                                     [OK]
consol/ubuntu-xfce-vnc                                 Ubuntu container with "headless" VNC session…   139                                     [OK]
ansible/ubuntu14.04-ansible                            Ubuntu 14.04 LTS with ansible                   95                                      [OK]
ubuntu-upstart                                         Upstart is an event-based replacement for th…   93                  [OK]
neurodebian                                            NeuroDebian provides neuroscience research s…   55                  [OK]
1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5   ubuntu-16-nginx-php-phpmyadmin-mysql-5          48                                      [OK]
ubuntu-debootstrap                                     debootstrap --variant=minbase --components=m…   40                  [OK]
nuagebec/ubuntu                                        Simple always updated Ubuntu docker images w…   23                                      [OK]
tutum/ubuntu                                           Simple Ubuntu docker images with SSH access     18                 
i386/ubuntu                                            Ubuntu is a Debian-based Linux operating sys…   16                
1and1internet/ubuntu-16-apache-php-7.0                 ubuntu-16-apache-php-7.0                        13                                      [OK]
ppc64le/ubuntu                                         Ubuntu is a Debian-based Linux operating sys…   12                
eclipse/ubuntu_jdk8                                    Ubuntu, JDK8, Maven 3, git, curl, nmap, mc, …   6                                       [OK]
darksheer/ubuntu                                       Base Ubuntu Image -- Updated hourly             5                                       [OK]
codenvy/ubuntu_jdk8                                    Ubuntu, JDK8, Maven 3, git, curl, nmap, mc, …   5                                       [OK]
pivotaldata/ubuntu                                     A quick freshening-up of the base Ubuntu doc…   2                 
smartentry/ubuntu                                      ubuntu with smartentry                          1                                       [OK]
1and1internet/ubuntu-16-sshd                           ubuntu-16-sshd                                  1                                       [OK]
paasmule/bosh-tools-ubuntu                             Ubuntu based bosh-cli                           0                                       [OK]
1and1internet/ubuntu-16-healthcheck                    ubuntu-16-healthcheck                           0                                       [OK]
ossobv/ubuntu                                          Custom ubuntu image from scratch (based on o…   0                 
pivotaldata/ubuntu-gpdb-dev                            Ubuntu images for GPDB development              0                  
1and1internet/ubuntu-16-rspec                          ubuntu-16-rspec                                 0                                       [OK]

使用命令 docker pull 来下载ubuntu镜像。用镜像加速后,下载镜像很快!

PS C:\WINDOWS\system32> docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
32802c0cfa4d: Pull complete
da1315cffa03: Pull complete
fa83472a3562: Pull complete
f85999a86bef: Pull complete
Digest: sha256:6d0e0c26489e33f5a6f0020edface2727db9489744ecc9b4f50c7fa671f23c49
Status: Downloaded newer image for ubuntu:latest
PS C:\WINDOWS\system32>

列举所有镜像

image.png

Docker 常用命令

  • 启动docker
    sudo service docker start

  • 停止docker
    sudo service docker stop

  • 重启docker
    sudo service docker restart

  • 列出Docker CLI命令
    docker
    docker container --help

  • 显示Docker版本和信息
    docker --version
    docker version
    docker info

  • Execute Docker image
    docker run hello-world

  • 列出镜像列表
    docker image ls

  • 列出docker容器 (running, all, all in quiet mode)
    docker container ls
    docker container ls --all
    docker container ls -aq

相关文章

网友评论

      本文标题:Docker windows安装并启用镜像加速

      本文链接:https://www.haomeiwen.com/subject/dxvykqtx.html