Windows Docker 桌面
- 系統要求:win10 64位專業版或企業版,
- 早期版本請使用 Docker Toolbox,
- Docker Desktop for Windows 下載地址,
版本說明
- Stable:穩定版,每個季度發布一次,
- Edge:測驗版,每月發布一次,
安裝運行
雙擊 Docker for Windows Installer.exe 即可安裝 Docker 程式,
安裝完成后,Docker會自動啟動, 任務欄中出現鯨魚圖示表示 Docker 正在運行,可以從終端訪問并使用 Docker,
打開 PowerShell 終端(非 PowerShell ISE),查看 Docker 版本:
docker version
測驗拉取鏡像和運行鏡像:
docker run hello-world
...
Hello from Docker!
...
右擊鯨魚圖示可以打開 Docker 面板和設定等功能,
查看已下載的鏡像:
docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest fce289e99eb9 15 months ago 1.84kB
查看所有容器:
docker container ls --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3189274c0687 hello-world "/hello" 34 minutes ago Exited (0) 34 minutes ago angry_liskov
使用幫助命令:
docker --help
docker container --help
docker container ls --help
docker run --help
探索 Docker
拉取 Ubuntu OS 映像,并在生成的容器內運行互動式終端:
> docker run --interactive --tty ubuntu:latest bash
- --interactive:打開 STDIN 與容器進行互動操作,
- --tty:使用偽終端,
進入容器后,在 root 提示符 # 后輸入:
root@8aea0acb7423:/# hostname
8aea0acb7423
顯示容器ID即為 Ubuntu OS 的主機名,
退出并停止容器運行:
root@8aea0acb7423:/# exit
>
查看所有容器:
docker container ls --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c67569f7e997 ubuntu "bash" 4 minutes ago Exited (0) About a minute ago blissful_nobel
3189274c0687 hello-world "/hello" 49 minutes ago Exited (0) 49 minutes ago angry_liskov
hello-world 和 ubuntu 容器均為隨機命名,
拉取并運行 nginx 網頁服務器,并命名為 webserver:
docker run --detach --publish 80:80 --name webserver nginx
- --detach:在后臺運行容器并列印出容器ID,
- --publish:發布一個容器的埠映射到主機中,
- --name:為容器分配一個命名,
在瀏覽器中訪問并顯示 Nginx 的默認頁:
http://localhost
在開發者工具中可以看到:
Status Code: 304 Not Modified
Remote Address: [::1]:80
查看所有運行中的容器:
docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8a47e6646e26 nginx "nginx -g 'daemon of…" 2 minutes ago Up 2 minutes 0.0.0.0:80->80/tcp webserver
通過容器名稱停止運行 nginx 容器:
docker container stop webserver
通過容器名稱移除容器:
docker container rm webserver laughing_kowalevski relaxed_sammet
參考:https://docs.docker.com/docker-for-windows/
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/73614.html
標籤:其他
上一篇:騰訊云 Serverless 產品動態 20200730
下一篇:安裝requests出現的問題
