1. 程式人生 > >Windows10下的docker安裝與入門

Windows10下的docker安裝與入門

 個人站點 :http://oldchen.iwulai.com/   

 

說明:本文是直接使用的Windows10的虛擬機器,不需要下載任何的工具和虛擬機器

在Windows上安裝Docker

docker現在已經支援Windows直接安裝了,可以直接從官網上下載,有穩定版和開發版。

首先是系統要求:

Windows 10 64位專業版,企業版和教育版,

Hyper-V要開啟
具體就是,首先要開啟cpu虛擬化功能,這個在BIOS裡面改,可能會不成功,回覆初始設定之後再改應該就可以了。
然後就是在 程式與功能>啟用或關閉windows功能

 中將Hyper-v開啟就可以了。

然後開始安裝

一路next.....
安裝會自動安裝 Docker Engine, Docker CLI client, Docker Compose, and Docker Machine.幾個工具

安裝完成之後會自動啟動,如果之前的環境沒有問題的話應該就可以啟動了。

然後用(cmd,PowerShell)試試docker命令

//檢視版本
C:\Users\63448>docker -v
Docker version 18.06.1-ce, build e68fc7a

 

//一些基本命令,可以--help 檢視幫助
C:\Users\63448>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0da0a10fa9d3 nginx "nginx -g 'daemon of…" 17 minutes ago Up 17 minutes 0.0.0.0:80->80/tcp webserver
81b213af6963 ubuntu "bash" 28 minutes ago Up 28 minutes distracted_morse

 

C:\Users\63448>docker version
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:21:34 2018
OS/Arch: windows/amd64
Experimental: false

Server:
Engine:
Version: 18.06.1-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:29:02 2018
OS/Arch: linux/amd64
Experimental: false

 

C:\Users\63448>docker info
Containers: 4
Running: 2
Paused: 0
Stopped: 2
Images: 3
Server Version: 18.06.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.93-linuxkit-aufs
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: linuxkit-00155dca2105
ID: DRF6:VUQC:ZEMD:VUBL:C6LH:UM44:W5TC:TDWY:ZWOG:AGSR:H7DV:OBXS
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 38
Goroutines: 70
System Time: 2018-11-01T02:23:34.2056891Z
EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

執行一個demo

C:\Users\63448>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已經可以正常運行了

 

//docker ps 可以管理container

//docker stop/start webserver 可以啟動停止之前生成的webserver

//docker rm -f webserver 可以刪除container

//映象可以用 docker images 檢視

//用 docker rmi <imageID>|<imageName> 可以刪除映象