1. What is Docker?
Wikipedia 定義:
Docker is a software technology providing containers, promoted by the company Docker, Inc. Docker provides an additional layer of abstraction and automation of operating-system-level virtualization on Windows and Linux. (Docker 是提供容器的軟件技術(shù)管跺,在 Linux 上提供了操作系統(tǒng)級虛擬化的額外層次抽象和自動化锁孟。)
Docker is an open source project to pack, ship, and run any application as a lightweight container. (Docker 是一個開源項目仗岸,用于將任何應(yīng)用程序作為輕型容器進行打包,運輸和運行揪惦。)
官方定義:
Docker is the world’s leading software containerization platform. (Docker 是軟件集裝箱化/容器化平臺)
Docker is the company driving the container movement and the only container platform provider to address every application across the hybrid cloud. (Docker 是解決跨混合云的應(yīng)用程序的唯一容器平臺提供商)
Docker 特性
-
agility-敏捷
:13倍加速軟件開發(fā)和部署,并立即響應(yīng)客戶需求 -
portability-可移植性
:消除“在我這里可以正常運行奥藓睢器腋!”問題,一次打包隨處運行钩杰;通過內(nèi)部和云環(huán)境獲得獨立性 -
security-安全
:通過內(nèi)置的安全功能和配置纫塌,在整個生命周期內(nèi)提供更安全的應(yīng)用程序 -
cost savings-節(jié)約成本
:優(yōu)化基礎(chǔ)設(shè)施資源的使用和簡化操作,節(jié)省50%總成本
MODERN APP PLATFORM - 現(xiàn)代APP平臺
The Docker platform is the only container platform to build, secure and manage the widest array of applications from development to production both on premises and in the cloud. (Docker 平臺是唯一的容器平臺榜苫,用于構(gòu)建护戳、保護和管理應(yīng)用程序,從開發(fā)到生產(chǎn)垂睬,在內(nèi)部和云中)
Docker 平臺特性
-
Simplicity-簡單
:Docker 為應(yīng)用程序創(chuàng)建和編排提供強大的工具 -
Openness-透明度
:采用開源技術(shù)和模塊化設(shè)計媳荒,可以輕松集成到現(xiàn)有的環(huán)境中 -
Independence-獨立
:Docker 在開發(fā)人員和 IT 之間以及應(yīng)用程序和基礎(chǔ)設(shè)施之間建立了分離關(guān)鍵點,以解鎖創(chuàng)新
Docker 平臺設(shè)計理念
-
DEVS
:Docker 使開發(fā)人員更自由驹饺,更具創(chuàng)造力钳枕,更快地運送更多的軟件 -
OPS
:通過跨所有容器化的應(yīng)用程序和服務(wù)的通用控制平臺獲得可視性,管理和安全性 -
ECOSYSTEM-生態(tài)系統(tǒng)
:Docker 是一個開放和可擴展的平臺赏壹,可輕松集成到現(xiàn)有環(huán)境中鱼炒,促進全球科技,商業(yè)合作伙伴的充滿活力的生態(tài)系統(tǒng)
參考
2. 安裝并運行 Docker
在 Mac 上安裝 Docker蝌借,見 Install Docker for Mac
一昔瞧、下載并安裝 Docker.dmg
二、運行 Docker
Where to go next
- Getting started provides an overview of Docker for Mac, basic Docker command examples, how to get help or give feedback, and links to all topics in the Docker for Mac guide.
- Troubleshooting describes common problems, workarounds, how to run and submit diagnostics, and submit issues.
- FAQs provides answers to frequently asked questions/為常見問題提供答案.
- Release Notes lists component updates, new features, and improvements associated with Stable and Edge releases/羅列組件更新菩佑,新功能和改進.
- Get Started with Docker provides a general Docker tutorial/提供一個通用的Docker教程.
3. 玩轉(zhuǎn) Docker
跟著 Get started with Docker 開始使用 Docker自晰。
3.1 檢查 Docker Engine/引擎, Compose/組裝, and Machine/機器的版本
? ~ docker --version
Docker version 17.09.0-ce, build afdb6d4
? ~ docker-compose --version
docker-compose version 1.16.1, build 6d1ac21
? ~ docker-machine --version
docker-machine version 0.12.2, build 9371605
3.2 探討應(yīng)用和運行示例
3.2.1 運行一些Docker命令驗證Docker是否按預期工作
? ~ docker version
......
# Docker daemon 未啟動
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
? ~ docker version
# Docker 客戶端
Client:
Version: 17.09.0-ce
API version: 1.32
Go version: go1.8.3
Git commit: afdb6d4
Built: Tue Sep 26 22:40:09 2017
OS/Arch: darwin/amd64
# Docker 服務(wù)端版本,API版本稍坯,Go版本
Server:
Version: 17.09.0-ce
API version: 1.32 (minimum version 1.12)
Go version: go1.8.3
Git commit: afdb6d4
Built: Tue Sep 26 22:45:38 2017
OS/Arch: linux/amd64
Experimental: true
? ~ docker ps
# 無容器運行中
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
? ~ 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. (Docker客戶端聯(lián)系Docker服務(wù)端守護進程)
2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (Docker守護進程從Docker Hub拉取“hello-world”鏡像)
3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. (Docker守護進程從該鏡像創(chuàng)建一個新的容器酬荞,該容器運行可執(zhí)行文件搓劫,生成當前正在讀取的輸出)
4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. (Docker守護進程將輸出的流式內(nèi)容傳輸?shù)紻ocker客戶端,Docker客戶端將其發(fā)送到您的終端)
Share images, automate workflows, and more with a free Docker ID/通過免費的Docker ID共享鏡像混巧,自動化工作流程等:
https://cloud.docker.com/
For more examples and ideas, visit/想了解更多示例和想法枪向,請訪問:
https://docs.docker.com/engine/userguide/
- Docker Hub: Dev-test pipeline automation, 100,000+ free apps, public and private registries
- Docker Cloud: The official cloud service for continuously delivering Docker applications
- Docker User Guides
3.2.2 啟動容器化的Web服務(wù)器
? ~ docker run -d -p 80:80 --name webserver nginx
122424b8077b791b42b31898eef3b77aa054a994b663fc832d5e90de430ac65a
# 啟動用戶態(tài)代理時出錯:80端口已使用
docker: Error response from daemon: driver failed programming external connectivity on endpoint webserver (0f305bfd15dcf2914f7bf2c815ed94412706f85e3a2d9d2e83ec7423d58a1726): Error starting userland proxy: Bind for 0.0.0.0:80: unexpected error (Failure EADDRINUSE).
? ~ docker run -d -p 80:80 --name webserver nginx
# 沖突:容器名稱"/webserver"已使用,您必須刪除(或重命名)該容器才能重用該名稱
docker: Error response from daemon: Conflict. The container name "/webserver" is already in use by container "122424b8077b791b42b31898eef3b77aa054a994b663fc832d5e90de430ac65a". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
? ~ docker rm webserver
webserver
Nginx啟動正常:Networking features in Docker for Mac
? ~ docker run -d -p 8080:80 --name webserver nginx
# 容器ID
61a674b351579ccc527f13f679ace017147789ae667dc5ff0caa275add1e898f
在Web瀏覽器中咧党,轉(zhuǎn)到 http://localhost:8080/ 打開主頁秘蛔。
3.2.3 查看容器詳細信息
? ~ docker ps
# 容器ID,鏡像名稱凿傅,運行命令缠犀,創(chuàng)建時間,運行狀態(tài)聪舒,端口映射辨液,容器名稱
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
61a674b35157 nginx "nginx -g 'daemon ..." About an hour ago Up About an hour 0.0.0.0:8080->80/tcp webserver
3.2.4 停止或移除容器或鏡像
停止或啟動容器:
? ~ docker stop webserver
webserver
? ~ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
? ~ docker start webserver
webserver
? ~ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
61a674b35157 nginx "nginx -g 'daemon ..." About an hour ago Up 1 second 0.0.0.0:8080->80/tcp webserver
? ~ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
61a674b35157 nginx "nginx -g 'daemon ..." About an hour ago Up 8 seconds 0.0.0.0:8080->80/tcp webserver
cecc48eb752e hello-world "/hello" 2 hours ago Exited (0) 2 hours ago pedantic_almeida
停止并移除運行中的容器:
? ~ docker rm -f webserver
webserver
列出本地鏡像:
? ~ docker images
# 倉庫,標簽箱残,鏡像ID滔迈,創(chuàng)建時間,鏡像大小
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest c59f17fe53b0 6 days ago 108MB
alpine latest 37eec16f1872 8 days ago 3.97MB
hello-world latest 05a3bd381fc2 7 weeks ago 1.84kB
首選項
包括 General被辑,F(xiàn)ile sharing燎悍,Advanced,HTTP proxy settings盼理,Docker Daemon
添加TLS證書
安裝bash完成
提供反饋并獲得幫助
Docker Store
Docker store is a component of the next-generation Docker Hub, and the best place to find compliant, trusted commercial and free software distributed as Docker Images.
The Docker Store - Find Trusted and Enterprise Ready Containers, Plugins, and Docker Editions/查找可信和企業(yè)就緒的容器谈山、插件和Docker版本
Docker Cloud
Docker Cloud - Build, Ship and Run any App, Anywhere
The official cloud service for continuously delivering Docker applications.
- Continuous integration (CI) for Docker/Docker持續(xù)集成
- Fully-managed Docker Registry Service/完全托管的Docker注冊服務(wù)
- Provision & manage Swarms/配置和管理集群
Where to go next
- Try out the walkthrough/嘗試演練 at Get Started.
- Dig in deeper with Docker Labs example walkthroughs and source code/深入挖掘Docker Labs的示例演練和源代碼.
- For a summary of Docker command line interface (CLI) commands, see Docker CLI Reference Guide/有關(guān)Docker命令行界面(CLI)命令的摘要,見Docker命令行界面參考指南.
- Check out the blog post/看看博客文章 Introducing Docker 1.13.0.
祝玩得開心宏怔!ˇ?ˇ
云舒奏路,2017.11.2,杭州