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
How to use Docker@HackerSir 11th
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
YUKAI
May 30, 2025
Education
70
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
How to use Docker@HackerSir 11th
YUKAI
May 30, 2025
More Decks by YUKAI
See All by YUKAI
WebAssembly 入門:在 Browser 上跑 C Code 是怎麼回事@HackerSir StudyGroup
yukai0xe
0
73
Docker Escape@HackerSir StudyGroup
yukai0xe
0
89
OAuth2.0 Easy Talk@HackerSir StudyGroup
yukai0xe
0
79
Discord Bot Junior Tutorial@HackerSir 11th
yukai0xe
0
44
XSS Everywhere@HackerSir 11th
yukai0xe
0
82
不要小看我的情報網_上吧網路爬蟲!!@HackerSir 11th
yukai0xe
0
70
Other Decks in Education
See All in Education
CLASSIFICATION OF CRUDE DRUGS
pawan_pharm
0
210
2026年度秋学期 統計学 講義の進め方と成績評価について (2026. 9. 28)
akiraasano
PRO
0
230
LEGO Geometry Tutorial
arnoknobbe
0
690
An Experiment in "Cross-Cultural Exchange" as a Method for Content Creation
naoji_taniguchi_ksk_0827
0
240
ちいかわを読め
uchi8977
1
390
未踏峰連山 Frontiers: Creating and Conquering Untrodden Peaks
ishii_mit
1
160
TISSUE
pawan_pharm
0
260
Soluciones al examen de Geografía 2026. JULIO (Convocatoria Extraordinaria)
juanmartin2026
1
20k
Introduction to M&A
bvr7352
0
230
[2026後期火5] 論理学(京都大学文学部 後期 第1回)「名前はあるのに、誰なのかわからない」
yatabe
0
120
Web Architectures - Lecture 2 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
Introduction - Lecture 1 - Web Technologies (1019888BNR)
signer
PRO
0
6.5k
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
225
10k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
Optimising Largest Contentful Paint
csswizardry
37
4k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
570
sira's awesome portfolio website redesign presentation
elsirapls
0
440
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
480
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
HDC tutorial
michielstock
2
950
Chasing Engaging Ingredients in Design
codingconduct
0
340
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.1k
Transcript
一鍵開服,創建你的虛擬世界 2025/03/18 by YuKai
01 為什麼你該學 Docker 02 如何使用 Docker 03 一個 Docker 不夠用,那就多用幾個
(docker compose) Outline 04 給我更多更多的 container
架服務會遇到的難題 我這跑得好好的 肯定是你的電腦有問題
為什麼你該學 Docker? 01
• 容器化技術(container) • 不需要 HyperVisor,直接使用 host machine 效能 • 以
Golang 語言開發 What is Docker
• 輕量級的虛擬化技術 • 將應用程式、環境一起打包 • 隔離彼此的應用程式,不受其他應用程式影響 容器化技術
• 輕鬆在任何環境部屬應用程式 ◦ Game server(Ex: Minecraft server) ◦ Web Application(Ex:
Frontend、Backend) ◦ Tools ◦ AI Agent(MCP) Docker 能幹嘛
• Registry • Image • Container Docker Architecture
Registry、Repository、Image Registry Repository1 Image-name:tag1 Image-name:tag2 Image-name:tag3 Repository2 Image-name:tag1 Image-name:tag2 Image-name:tag3
• Registry 又分 Public 和 Private ◦ Docker Hub ◦
GitLab container registry ◦ Google Container Registry(gcr.io) Registry、Repository、Image
• Image 是一個 readonly 的模板,包含了必要的 os、application、package • Container 按照 image
建立而成,container 彼 此是獨立的,只要刪掉 container 就可以移除上面 的所有資料 Image、Container
Virtual Machine vs. Container VM Container 啟動時間 基本上都要幾分鐘 快速 容量
大(GB) 小(MB) 效能 較慢 較快 Host machine 可支撐的數量 數十個 數百個 複製環境 較慢 較快
• Play with docker • Docker Install 教學 Docker Install、Online
Docker
如何使用 Docker 02 How to TCPdump effectively in Docker
• 拉取 Image • 建立 container • 啟用/停止 container •
列出 container / image • 刪除 container / image Docker 常見指令
• 拉取 image,預設 latest • 拉取特定 tag 的 image 常見指令
– 拉取 Image docker pull [image name] docker pull [image name]:[tag]
常見指令 – 建立 container docker run –d --name [container name]
[image name] [other command] -d:背景執行 -it:提供交互模式 --name:定義容器名稱 -e:加入環境變數 -p:綁定 host 和 container 的 port --rm:當 container 不使用時就刪除
• 啟用 container • 停止 container 常見指令 – 啟用/停止 container
docker start [container name] docker stop [container name]
• 列出已啟用的 container • 列出所有 container • 列出所有 image 常見指令
– 列出 container/image docker ps docker ps -a docker images
• 刪除沒有啟用的 container • 刪除未使用的 image 常見指令 – 刪除 container/image
docker rm [container name] docker rmi [image name]
• 進入 container 查看 • 查看 image/container 詳細資訊 一些實用的指令 docker
exec –it [container name] bash docker inspect [image name]/[container name] docker run –it --name [container name] [image name] bash
• 列出 container log • 列出 image history 一些實用的指令 docker
logs [container name] docker logs [container name] -f docker history [image name]
• 拉取 Ubuntu Image 並輸出 Hello World • 拉取一個你有興趣的 Image
並將其建立出一個 container Lab 1 docker pull ubuntu:latest docker run --name ub-1 ubuntu echo hello wolrd
簡單架一個 web server,首先新增 main.py 建立自己的 Image from flask import Flask
app = Flask(__name__) @app.route('/') def home(): return "Hello, Flask!" if __name__ == '__main__': app.run(host='0.0.0.0', debug=True)
建立一個 Dockerfile Dockerfile FROM python:3.9-slim WORKDIR /app COPY . /app
RUN pip install --no-cache-dir -r requirements.txt EXPOSE 80 CMD ["python", "main.py"]
FROM python:3.9-slim WORKDIR /app COPY . /app RUN pip install
--no-cache-dir -r requirements.txt EXPOSE 80 CMD ["python", "main.py"] Dockerfile 拉取 base image 延伸閱讀:docker 鏡像差異
FROM python:3.9-slim WORKDIR /app COPY . /app RUN pip install
--no-cache-dir -r requirements.txt EXPOSE 80 CMD ["python", "main.py"] Dockerfile 新建 /app 目錄到 image
FROM python:3.9-slim WORKDIR /app COPY . /app RUN pip install
--no-cache-dir -r requirements.txt EXPOSE 80 CMD ["python", "main.py"] Dockerfile 複製現在的目錄到 image 的 /app 底下
FROM python:3.9-slim WORKDIR /app COPY . /app RUN pip install
--no-cache-dir -r requirements.txt EXPOSE 80 CMD ["python", "main.py"] Dockerfile 執行指令(建立 image 時)
補充:生成 requirements 這樣就可以將需要的套件列入 requirements.txt pip freeze > requirements.txt
FROM python:3.9-slim WORKDIR /app COPY . /app RUN pip install
--no-cache-dir -r requirements.txt EXPOSE 80 CMD ["python", "main.py"] Dockerfile 開放 80 port
FROM python:3.9-slim WORKDIR /app COPY . /app RUN pip install
--no-cache-dir -r requirements.txt EXPOSE 80 CMD ["python", "main.py"] Dockerfile 執行指令(構建 container 時)
• 建立 image • 刪除 none image 常見指令 docker build
-t [image name] . docker image prune
使用 Dockerfile 建立簡單的 Application Lab2 docker build -t [image name]
. docker run –d --name [container name] –p 5000:5000 [image name]
Docker Compose 一個 Docker 不夠用,那就多用幾個 03
• 幫助定義、運行、管理多個 docker • 使用 yaml 配置 • 保持整套系統的一致性 What
is Docker Compose?
• 建立一個 compose.yml • version:使用哪個版本 • services:有哪些 application Docker Compose
version: '3.8' services: flask: build: . ports: - "5000:5000" environment: - FLASK_ENV=development tunnel: image: cloudflare/cloudflared command: --url http://flask:5000 depends_on: - flask
flask: build: . ports: - "5000:5000" environment: - FLASK_ENV=development 第一個
application(flask) Docker Compose 用同個目錄下的 Dockerfile 建構 綁定 5000 port 設定環境變數
第二個 application(tunnel) Docker Compose tunnel: image: cloudflare/cloudflared command: --url http://flask:5000
depends_on: - flask 使用哪個 image 等待 flask 建立好 在 container 執行的指令
記得先切到 compose.yml 同個目錄下 • 根據 compose.yml 建立所有 image 和 container
• 將 compose.yml 的 container 移除 常用指令 – 建立/啟用/移除 docker-compose build up -d docker-compose down
嘗試用 Docker compose 建立先前的 Service Lab3 docker-compose build up -d
給我更多更多的 Container 04
Volume:避免資料在容器刪除後被移除 More Docker Usage Host Machine Container /my_database/sqlite.db /certs/certificate.crt /my_db
/my_certs
Network:建立容器間溝通 • bridge:預設模式 More Docker Usage 圖源
Network:建立容器間溝通 • overlay:能使不同 docker daemon 通信 More Docker Usage 圖源
Network:建立容器間溝通 • macvlan ◦ 能使用 physical address More Docker Usage
圖源
Network:建立容器間溝通 • host ◦ 會使得 Network 隔離效果消失 ◦ 安全風險(延伸資料:docker escape)
More Docker Usage
Docker Swarm • 在多台實體機器上執行 Container,形 成一個叢集(Cluster)的一個工具 Kubernets(K8s) • 用於自動部署、擴充和管理「容器化應用 程式」的開源系統
More Container
• Dockage • Portainer • Docker Desktop I need Some
GUI
None