在Windows上安装Docker

在Windows上安装Docker

本文翻译自docs.docker.com有删减,如果有时间的话我会把剩下的文档也尽量翻译整理下来。
docker现在已经支持Windows直接安装了,可以直接从官网上下载,有稳定版和开发版。

首先是系统要求:

Windows 10 64位专业版,企业版和教育版,

64bit Windows 10 Pro, Enterprise and Education (1511 November update,
Build 10586 or later). In the future we will support more versions of
Windows 10.

Hyper-V要打开
具体就是,首先要打开cpu虚拟化功能,这个在BIOS里面改,可能会不成功,回复初始设置之后再改应该就可以了。
然后就是在 程序与功能>启用或关闭windows功能 中将Hyper-v打开就可以了。

还有些其他提醒和要求,不过不是很重要

Docker for Windows requires Microsoft Hyper-V to run. After Hyper-V is
enabled, VirtualBox will no longer work, but any VirtualBox VM images
will remain.

然后就是安装了

这个,点击下载下来的文件,next,next就好了。
安装会自动安装 Docker Engine, Docker CLI client, Docker Compose, and Docker Machine.几个工具

安装完成之后会自动启动,如果之前的环境没有问题的话应该就可以启动了。

这个时候就可以试试docker命令了

cmd.exe, PowerShell或者其他shell工具都可以。

  //查看版本
  PS C:\Users\samstevens> docker --version
  Docker version 1.12.0, build 8eab29e, experimental

  PS C:\Users\samstevens> docker-compose --version
  docker-compose version 1.8.0, build d988a55

  PS C:\Users\samstevens> docker-machine --version
  docker-machine version 0.8.0, build b85aac1
   //一些基本命令,可以--help 查看帮助
   C:\Users\samstevens> docker ps
   CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

   C:\Users\Vicky> docker version
   Client:
   Version:      1.12.0
   API version:  1.24
   Go version:   go1.6.3
   Git commit:   8eab29e
   Built:        Thu Jul 28 21:04:48 2016
   OS/Arch:      windows/amd64
   Experimental: true

   Server:
   Version:      1.12.0
   API version:  1.24
   Go version:   go1.6.3
   Git commit:   8eab29e
   Built:        Thu Jul 28 21:04:48 2016
   OS/Arch:      linux/amd64
   Experimental: true

   C:\Users\Vicky> docker info

运行一个demon

C:\Users\samstevens> 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.

//如果出现上面这些说明安装成功,docker已经可以正常运行了

运行一个Ubuntu container

C:\Users\samstevens> 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
//输入 exit 可以退出

启动一个Dockerized webserver

C:\Users\samstevens> 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 可以看到欢迎界面
//docker ps 可以管理container
//docker stop/start webserver 可以启动停止之前生成的webserver
//docker rm -f webserver 可以删除container  
//镜像可以用 docker images 查看
//用 docker rmi <imageID>|<imageName> 可以删除镜像

目前就这么多吧,待续,,,

猜你喜欢

转载自blog.csdn.net/lucifly/article/details/52983758