登录  /  注册

在Windows上如何安装Docker的代码实例分享

黄舟
发布: 2017-06-07 09:37:04
原创
1642人浏览过

下载Docker for Windows

稳定版

准备安装Docker for Windows
安装前请保障 Windows10 版本大于或等于 1703,os版本大于或等于 15063
我在版本1607下安装就会有找不到引用汇编文件的错误
必须启用Hyper-V软件包才能使Docker for Windows工作。如果您的系统不满足这些要求,您可以安装Docker Toolbox,它使用Oracle Virtual Box而不是Hyper-V。
在 Windows 10 上安装 Hyper-V 网址

安装Docker for Windows
双击InstallDocker.msi以运行安装程序。

检查Docker
打开PowerShell,输入以下代码

PS C:\Users\Docker> docker --version
Docker version 17.03.0-ce, build 60ccb22

PS C:\Users\Docker> docker-compose --version
docker-compose version 1.11.2, build dfed245

PS C:\Users\Docker> docker-machine --version
docker-machine version 0.10.0, build 76ed2a6
登录后复制

运行docker run hello-world来测试从Docker Hub拉一个镜像并启动一个容器。

PS C:\Users\jdoe> 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:
The Docker client contacted the Docker daemon.
The Docker daemon pulled the "hello-world" image from the Docker Hub.
The Docker daemon created a new container from that image which runs the executable that produces the output you are currently
reading.
The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
登录后复制

尝试更有野心的东西,并使用此命令运行Ubuntu容器。
这将下载ubuntu容器镜像并启动它。以下是在powerhell中运行此命令的输出。

PS C:Usersjdoe> docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally latest: Pulling from
library/ubuntu 5a132a7e7af1: Pull complete fd2731e4c50c: Pull complete
28a2f68d1120: Pull complete a3ed95caeb02: Pull complete Digest:
sha256:4e85ebe01d056b43955250bbac22bdb8734271122e3c78d21e55ee235fc6802d
Status: Downloaded newer image for ubuntu:latest
登录后复制

使用docker开启nginx服务器

PS C:\Users\jdoe> docker run -d -p 80:80 --name webserver nginx
登录后复制
Unable to find image 'nginx:latest' locally latest: Pulling from
library/nginx
fdd5d7827f33: Pull complete a3ed95caeb02: Pull complete 716f7a5f3082:
Pull complete 7b10f03a0309: Pull complete Digest:
sha256:f6a001272d5d324c4c9f3f183e1b69e9e0ff12debeb7a092730d638c33e0de3e
Status: Downloaded newer image for nginx:latest
dfe13c68b3b86f01951af617df02be4897184cbf7a8b4d5caf1c3c5bd3fc267f
访问http://localhost/以显示nginx起始页。
登录后复制

使用 docker ps 命令查看容器列表
使用 docker images 命令查看镜像列表

加速器

在系统右下角托盘图标内右键菜单选择 Settings,打开配置窗口后左侧导航菜单选择 Docker Daemon。编辑窗口内的JSON串,填写如阿里云、DaoCloud之类的加速器地址,如:

 {
     "registry-mirrors": [
       "https://sr5arhkn.mirror.aliyuncs.com",
       "http://14d216f4.m.daocloud.io"
     ],
     "insecure-registries": []
   }
登录后复制

以上就是在Windows上如何安装Docker的代码实例分享的详细内容,更多请关注php中文网其它相关文章!

相关标签:
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 技术文章
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2023 //m.sbmmt.com/ All Rights Reserved | 苏州跃动光标网络科技有限公司 | 苏ICP备2020058653号-1

 | 本站CDN由 数掘科技 提供

登录PHP中文网,和优秀的人一起学习!
全站2000+教程免费学