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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Bo-Yi Wu
April 22, 2016
Technology
1.3k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Docker 基礎介紹與實戰
blog:
https://blog.wu-boy.com/2016/04/introduction-to-docker/
Bo-Yi Wu
April 22, 2016
More Decks by Bo-Yi Wu
See All by Bo-Yi Wu
從觀望到全公司落地:AI Agentic Coding 導入實戰 — 流程整合與安全治理
appleboy
1
2.4k
打造你的 AI 工作流:Agent Skill + MCP 實戰工作坊
appleboy
0
1.9k
從開發到部署全都交給 AI:實作 AI 驅動的自動化流程
appleboy
1
390
AI 不只幫你寫 Code: 當專案從 300 暴增到 1500, 我們如何撐住 DevOps
appleboy
1
560
Agent Skill 是什麼?對軟體產業帶來的變化
appleboy
0
3.8k
用 Claude Code + GitHub Copilot Review 打造 AI 驅動的開發流程
appleboy
0
2.4k
戰略轉變:從建構 AI 代理人到發展可擴展的技能生態系統
appleboy
0
370
The Smart Choice for Command-Line Image Resizing
appleboy
0
81
SSH for GitHub Actions
appleboy
0
560
Other Decks in Technology
See All in Technology
2026-10-01_MagicPod_QAハーネスエンジニアリングとQA組織の未来像
ynisqa1988
1
530
プロダクト価値を、 チームが使える判断軸に変える
vivion
0
110
OpenSharing について熱く語る〜AI アセットの共有について〜
kameitomohiro
0
230
ファミコンでPHPを動かす / PHP on the Famicom side b
tomzoh
0
140
Claude起点の仕様駆動開発
tanakaseiya
0
390
LLM機能を自作して分かるSnowflake Cortex AIの強み
nayuts
0
300
More Freedom on the Same Shared GPU Cluster: A Small Team’s Experience with vCluster
nttcom
0
140
形式手法を使って仕様をコーディングしよう
mikanichinose
0
180
AI時代だからこそ推したい!Gitコマンド再入門
munakata
0
150
FactoryBotアンチパターン / factory_bot anti-patterns
toshimaru
0
140
OSC2026on_the-world-is-waiting-for-your-voice.pdf
naruoga
0
350
AIは爆速なのに、私が詰まっていた話 ― 音声入力と鳴くマスコットでボトルネックを削る
yama3133
0
520
Featured
See All Featured
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
520
Speed Design
sergeychernyshev
33
2.1k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
350
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
620
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
66k
Unsuck your backbone
ammeep
672
58k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
540
Claude Code のすすめ
schroneko
67
230k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Transcript
Docker 基礎介紹與實戰 Bo-Yi Wu 2016.04.21 1
關於我 • https://blog.wu-boy.com • https://github.com/appleboy • https://www.facebook.com/appleboy46 2
為什麼需要使用 Doecker 3
Why • 新人環境建置 (蜜月期?) • 多種環境建置及版本測試 – Node 4.x, 5.x ..
– PHP 5.6, 5.7 .. – Wordpress, Discourse, Gogs, Gitlab …. 4
多人共用一台Build Server 5
問題是 … • 宅宅 A: 那個誰誰,可以先停掉你的程序嗎? • 宅宅 B:
CPU 跟 Ram 都爆了啦 …. • 宅宅 C: 編譯個 Router Code 要半小時啊 …. • 宅宅 D: 趁半夜沒人的時候再來用 (加班狂?) 6
7
軟體工程師 • 做事效率低落 • 每天產能有限 • 浪費很多時間在 Build
Code 上 • 如果 Server 壞了,是全 Team 放假嗎? • 週末或平日晚上頻加班 … 8
聊聊Web前後端開發環境 9
前端 vs 後端 API Server 前端 Team 後端 Team Deploy
Deploy 10
如果 API Server 掛掉 前端團隊全部都在等 後端工程師修復 11
這時候就需要 Docker 了 12
解決 • 工程師不再抱怨 Build Server 慢 – 不會再找我麻煩了 (誤)
• 前後端各自獨立作業 – 前端各自有獨立開發環境 • 要測試 Service (Wordpress, Jenkins, Gogs) – 不需要安裝任何 redis, mysql, php 等環境 13
What’s Docker? 14
Docker vs. Virtual Machine 15
基本觀念 • Docker 映像檔 (Images) • Docker 容器 (Container)
• Docker 倉庫 (Repository) 16
Docker Images 17
Docker container • 從 images 建立新的 container • 每個容器互相隔離,保證安全 •
可寫可讀 (Read, Write) 18
Docker Repository Docker 倉庫概念跟 Git 類似 你可以想成類似 Github 託管服務 19
Image Image Container Container Docker Registry Pull Run Commit Push
20
Image Docker Registry Pull docker pull ubuntu 21
Image Container Docker Registry Pull Run docker run –t –i
ubuntu /bin/bash 22
Image Container Container Docker Registry Pull Run apt-get update 23
Image Image Container Container Docker Registry Pull Run Commit docker
commit 24
Image Image Container Container Docker Registry Pull Run Commit Push
docker push 25
Docker 安裝 Mac OS X: https://goo.gl/05XMnB Linux: https://goo.gl/wRpzlT 26
Docker images https://hub.docker.com/ 請先申請帳號密碼 27
Docker images • docker pull ubuntu:14.04 – ubuntu: image name – 14.04:
tag name, default is “latest” – host: registry.hub.docker.com 28
列出本機端 images docker images 29
30
進入容器內 (秒入) docker run –ti ubuntu:14.04 /bin/bash root@9cadb3b3e718:/# 31
可以做什麼? 做你想做的任何事情 Install nginx, php, mysql …. 32
儲存目前的工作狀態 docker commit –m ‘test’ –a ‘Bo-Yi Wu’ 9cadb3b3e718
appleboy/test:1.0 33
從上次 commit 進入 bash docker run –t –i appleboy/test:1.0
/bin/bash 34
玩壞了沒關係 docker run –ti ubuntu:14.04 /bin/bash 35
Demo 36
Ubuntu images apt-get update Nginx Apache PHP 5.3 PHP 5.4
PHP 5.6 PHP 5.7 37
Ubuntu images apt-get update docker pull ubuntu:14.04 docker run –ti
ubuntu:14.04 /bin/bash $ apt-get update && apt-get –y upgrade $ exit docker commit –m “test” xxxxx test/base:1.0 38
Ubuntu images apt-get update Nginx docker run –ti test/base:1.0 /bin/bash
$ install nginx …… $ exit docker commit –m “test” xxxxx test/nginx:1.0 39
Ubuntu images apt-get update docker run –ti test/base:1.0 /bin/bash $
install apache…… $ exit docker commit –m “test” xxxxx test/apache:1.0 Apache 40
Ubuntu images apt-get update Nginx docker run –ti test/nginx:1.0 /bin/bash
$ install php5.3 …… docker commit –m “php” xx test/php:5.3 PHP 5.3 41
練習 前端建立 node 4 及 node 5 環境 後端建立 php6
及 php7 環境 驗證 images 是否有該執行檔 42
有沒有覺得打指令很累 有沒有一個指令就把 images 建立好? 43
這時候你就需要 Dockerfile $ touch Dockerfile 44
45
Dockerfile 好理解,易於管理,還可以版控 46
透過 Dockerfile 建立 local images docker build –t myimage -f
Dockerfile . 47
啟動自製 images 48
Ubuntu images eth0 8000 port Host Docker bridge eth0 5467
port Docker run –d –p 8000 hello 49
Ubuntu images eth0 8000 port Host eth0 80 port Docker
run –d –p 80:8000 hello Docker bridge 50
Hello eth0 8000 port Host Docker bridge eth0 80 port
Docker run –d ––name hello –p 80:8000 hello 51
該如何把目錄 mount 到 Container 內呢? 52
Hello eth0 8000 port Host Docker bridge eth0 80 port
Docker run –d –v /opt/test:/home/test ––name hello –p 80:8000 hello /opt/test /home/test 53
如何看 Docker log docker ps docker logs name 54
如何進入容器 docker ps docker exec –ti name /bin/bash 55
停止,啟動容器 docker ps docker stop name docker start name
docker restart name 56
連接多個服務 MySQL, Redis …. 57
Ubuntu eth0 8000 port Host Docker bridge eth0 80 port
Docker run –d ––link redis:redis –p 80:8000 hello 58
啟動 Mysql, Redis • docker run –d ––name my-db –e
MYSQL_ROOT_PASSWORD=1234 mysql • docker run –d ––name my-redis redis 59
連接 Mysql 及 Redis Docker run –ti ––link my-db:db \
––link my-redis:redis \ ubuntu /bin/bash 60
建立 Wordpress • docker run –d ––name my-db \ –e
MYSQL_ROOT_PASSWORD=1234 \ mysql • docker run ––name my-wp \ --link my-db:mysql -d \ -p 8080:80 wordpress 61
如果有5個以上服務需要連接呢 這時候你就需要 docker-compose.yml 62
wordpress: image: wordpress links: - db:mysql ports: - 8080:80 db:
image: mariadb environment: MYSQL_ROOT_PASSWORD: test 63
docker-compose 啟動 docker-compose up –d create and start containers 64
docker-compose 列表 docker-compose ps 65
用 docker ps 也可以 66
docker-compose • Docker-compose stop (停止服務) • Docker-compose start (啟動服務) •
Docker-compose rm (移除全部 container) 67
平行擴展 DB 架構 docker-compose scale db=5 68
用 Docker 來測試 69
事前準備 • 準備相關環境 – Node 4 – Node 5 – PHP5 – PHP6
– PHP7 Images Dockerfile Yoyo/node:4 Yoyo/node:5 Yoyo/php:6 Yoyo/php:7 70
Testing node4 Testing node5 Testing php7 Testing php6 71
Docker run –rm \ –v folder1:folder2 \ --link mysql:mysql \
--workdir=/app \ -e DEV=Testing\ yoyo:node5 \ /bin/bash –c “npm test” 72
Best Practices Cheat Sheet https://goo.gl/4CgNkd 73
74
Any Question? 75