下載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中文網其他相關文章!