Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
讓軟體開發與應用更自由 - 使用 Docker 容器技術
Search
Yu-Lung Shao
June 25, 2017
Programming
90
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
讓軟體開發與應用更自由 - 使用 Docker 容器技術
20170625 台中自由軟體愛好者社群
#Docker
#LaraDock
Yu-Lung Shao
June 25, 2017
Other Decks in Programming
See All in Programming
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
220
AIエージェント時代のコードレビューを設計する
nogu66
6
2.6k
自分的「カンファレンスの楽しみ方」
syumai
0
200
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
130
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
6.4k
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
6
1.7k
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
700
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
3
530
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
440
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
130
How I Stole PSI from Android Studio - DroidKaigi2026
worker8
0
110
デプロイ直後のレイテンシスパイクを調べたら、 Railsの仕様にたどり着いた
nhsykym
0
120
Featured
See All Featured
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
520
Accessibility Awareness
sabderemane
1
210
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
202
76k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.6k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
500
From π to Pie charts
rasagy
0
360
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
2
3.8k
Producing Creativity
orderedlist
PRO
348
41k
A Soul's Torment
seathinner
7
3.6k
Transcript
讓軟體開發與應⽤用更更⾃自由 使⽤用 docker 容器技術 2017.06.25 @台中⾃自由軟體愛好者社群(TFC)
講者 • 邵⽟玉龍 (Allen Shao) • 網路路暱稱:bestlong • 在⼿手⼯工具製造公司內擔任資訊⼈人員 •
程式開發、系統維運 • 持續學習探索 DevOps 中
⼤大綱 • Docker 基本概念念 • PHP 開發者的環境演變 • 會介紹 LaraDock
• 命令列列打字好累有沒有更更⽅方便便的管理理⼯工具 • Docker 使⽤用空間⼤大掃除
Docker 基本概念念
什什麼是 Docker? • Software Container Platform • Application delivery technology
• Not VMs • 比較像是隔離環境與共享資源⽽而不是模擬 • 獨棟房屋 vs 多住⼾戶公寓 Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications, whether on laptops, data center VMs, or the cloud.
Docker vs VM 圖片來來源 https://www.docker.com/what-container
VM Docker Size ⼤大 ⼩小 Startup 慢 快 Integration 不易易
容易易 簡單比較
Docker with VM 圖片來來源 https://www.docker.com/what-container
Why docker • Developer • 可以解決只在我的電腦可以正常運作的囧況 • 多⼈人協同開發讓開發環境統⼀一 • 新成員快速建置環境
• 經常要切換新舊環境版本 • Operator (System Admin) • build, ship, test, and deploy apps ⾃自動化 • Enterprise • DevOps, agile • cloud-ready, optimal costs
Docker Editions • Docker CE (Community Edition) • Stable •
Edge • Docker EE (Enterprise Edition) • Basic • Standard • Advanced • Moby ? • https://mobyproject.org/
Support Platform • Linux • apt-get install docker.io • macOS
• 舊版⽤用 boot2docker • Windows • 舊版⽤用 boot2docker • Win10 x64
Docker Engine 圖片來來源 https://docs.docker.com/engine/docker-overview/
• 三個基本要素 • Image 映像檔 • Container 容器 • Registry
(Repostory 倉庫) • 兩兩個基本必要 • 網路路 • ⾜足夠的硬碟空間
先來來感覺⼀一下 • 沒有環境的可先使⽤用線上服務 http://play-with-docker.com/ • docker version • docker info
• docker ps • docker images • docker pull hello-world • docker run hello-world • docker run -it ubuntu bash
Docker architecture Volumes dockerfile Client/Server 架構 圖片來來源 https://docs.docker.com/engine/docker-overview/
Docker 映像檔 • 唯讀的模板 • 分層結構,有層數上限 • 建立 Container 的模版
• Docker Hub https://hub.docker.com/
Docker 映像檔 分層結構圖⽰示 圖片來來源 https://blog.jayway.com/2015/03/21/a-not-very-short-introduction-to-docker/
Dockerfile • 打造映像檔的藍藍圖 • 需要具備 Linux 系統管理理的知識
Dockerfile commands • 命令有效範圍區分為建構時期與啟動容器時期 Build Both (Build/Run) Run FROM MAINTAINER
COPY ADD RUN ONBUILD .dockerignore WORKDIR USER CMD ENV EXPOSE VOLUME ENTRYPOINT https://docs.docker.com/engine/reference/builder/ 第⼀一個指令必須為 ‘FROM’
Dockerfile 設計原則 • 先求正確建構 • ⼀一個指令⼀一個 RUN • 再進⾏行行最佳化 •
減少映像檔分層 • ⽤用 && 合併 RUN 指令 • 容量量最⼩小化 • 不需要的檔案不要 ADD (應⽤用 .dockerignore) • 刪除暫存檔
Demo
PHP 開發者的⼯工作環境演變 使⽤用 HTTP + PHP + DB 組合
• Windows 開發環境 • ⼿手動安裝 • XAMPP • WampServer •
AppServ • 多重開機進入 Linux 環境 • 步驟繁瑣、版本固定 開發 PHP 演進 - 本機
開發 PHP 演進 - 遠端主機 • 在家中或公司架設主機 • Linux ⽤用
telnet, ssh, VNC 連入 • Windows ⽤用遠端桌⾯面連入 • 必須要有網路路
開發 PHP 演進 - 本機VM • VMware • VirtualBox •
Vargrant • ⽤用 vargrantfile ⾃自動化安裝、設定、管理理多個VM • 虛擬磁碟很佔⽤用空間 • VM 很耗資源,需要較⾼高階的電腦
開發 PHP 演進 - 本機容器 • docker 單⼀一容器全包 • 適合開發與測試,效能差
• docker 多個容器分散架構 • 指令太繁瑣,要對 Docker Network 熟悉 • docker-compose 多容器的管理理⼯工具 • 適合開發與⽣生產環境 • 預設設定檔 docker-compose.yml • 介紹使⽤用 LaraDock http://laradock.io/
Demo
命令列列打字好累有沒有 更更⽅方便便的管理理⼯工具
更更⽅方便便的管理理⼯工具 • GUI • Kitematic (MacOS、Windows) https://kitematic.com/ • WebUI •
Portainer https://portainer.io/ • Shipyard https://shipyard-project.com/ • Rancher http://rancher.com/rancher/ • Kubernetes https://kubernetes.io/
Docker 使⽤用空間⼤大掃除
Docker 玩著玩著就佔⽤用了了很多的硬 碟空間 • 三個需要清理理的部分 • 容器 • 映像檔 •
Volume • 強制釋放佔⽤用空間 (macOS)
清理理容器 刪除指定執⾏行行中容器 docker rm CONTAINER 刪除全部執⾏行行中容器 docker kill $(docker ps
-q) 刪除所有容器 docker rm $(docker ps -aq) 強制刪除所有容器 docker rm -f $(docker ps -aq) 刪除已停⽌止的容器 docker rm $(docker ps -aq -f status=exited) 請⼩小⼼心使⽤用:刪除容器會遺失讀寫層的資料 過濾條件請參參考 https://docs.docker.com/engine/reference/ commandline/ps/#filtering
清理理映像檔 刪除指定映像檔 docker rmi IMAGE 刪除沒有建立容器的映像檔 docker rmi $(docker images
-q) 刪除沒有TAG的映像檔 docker rmi -f $(docker images -q -f dangling=true) 過濾條件請參參考 https://docs.docker.com/engine/reference/ commandline/images/#filtering
清理理 Volume 刪除孤兒 volume docker volume rm $(docker volume ls
-q -f dangling=true) 強制刪除所有 volume docker volume rm -f $(docker volume ls -q) 請⼩小⼼心使⽤用:刪除 volume 會遺失資料 過濾條件請參參考 https://docs.docker.com/engine/reference/ commandline/volume_ls/#filtering
強制釋放佔⽤用空間 (macOS) OOXX 該刪的都刪了了,怎麼 Host OS 磁碟空間還是沒釋放? 反正都刪光了了,試試看跑 Reset to
factory defaults
總結 • Docker 能更更快速的建置開發或⽣生產環境 • 讓系統架構即為程式碼 • 開發者學到 docker-compose 階段就很⾜足夠了了
• Volume ⼀一定要弄弄清楚,避免發⽣生資料遺失事件
學習資源 • https://docs.docker.com/ • Docker — 從入⾨門到實踐 • https://www.gitbook.com/explore
Q&A