Enviar búsqueda
Cargar
Docker應用
•
91 recomendaciones
•
8,664 vistas
Jui An Huang (黃瑞安)
Seguir
Docker 簡介
Leer menos
Leer más
Software
Denunciar
Compartir
Denunciar
Compartir
1 de 26
Descargar ahora
Descargar para leer sin conexión
Recomendados
Introduzione a Docker (Maggio 2017) [ITA]
Introduzione a Docker (Maggio 2017) [ITA]
Valerio Radice
Introduction to Docker - IndiaOpsUG
Introduction to Docker - IndiaOpsUG
Ajeet Singh Raina
Docker 基礎介紹與實戰
Docker 基礎介紹與實戰
Bo-Yi Wu
Intro to Docker November 2013
Intro to Docker November 2013
Docker, Inc.
Git best practices workshop
Git best practices workshop
Otto Kekäläinen
Docker internals
Docker internals
Rohit Jnagal
Jenkins
Jenkins
Roger Xia
Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
Edureka!
Recomendados
Introduzione a Docker (Maggio 2017) [ITA]
Introduzione a Docker (Maggio 2017) [ITA]
Valerio Radice
Introduction to Docker - IndiaOpsUG
Introduction to Docker - IndiaOpsUG
Ajeet Singh Raina
Docker 基礎介紹與實戰
Docker 基礎介紹與實戰
Bo-Yi Wu
Intro to Docker November 2013
Intro to Docker November 2013
Docker, Inc.
Git best practices workshop
Git best practices workshop
Otto Kekäläinen
Docker internals
Docker internals
Rohit Jnagal
Jenkins
Jenkins
Roger Xia
Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
Edureka!
Hybrid automation framework
Hybrid automation framework
doai tran
FirefoxOS and its use of Linux (a deep dive into Gonk architecture)
FirefoxOS and its use of Linux (a deep dive into Gonk architecture)
Aimee Maree Forsstrom
Docker introduction
Docker introduction
Phuc Nguyen
Installing and Running Postfix within a Docker Container
Installing and Running Postfix within a Docker Container
Docker, Inc.
Docker architecture-04-1
Docker architecture-04-1
Mohammadreza Amini
Cross platform app development with flutter
Cross platform app development with flutter
Hwan Jo
Report portal
Report portal
COMAQA.BY
Linux Audio Drivers. ALSA
Linux Audio Drivers. ALSA
GlobalLogic Ukraine
Introduction to Docker
Introduction to Docker
Pubudu Jayawardana
Installing and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command line
dotCloud
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Boni García
Git training v10
Git training v10
Skander Hamza
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
Edureka!
Flutter
Flutter
shreyash singh
Docker, LinuX Container
Docker, LinuX Container
Araf Karsh Hamid
Docker Introduction
Docker Introduction
Robert Reiz
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and Containers
Yajushi Srivastava
Docker 101 - Nov 2016
Docker 101 - Nov 2016
Docker, Inc.
introduction to flutter ppt - free download
introduction to flutter ppt - free download
RajatPalankar2
Web Development with Python and Django
Web Development with Python and Django
Michael Pirnat
認識那條鯨魚 Docker 初探
認識那條鯨魚 Docker 初探
仲昀 王
Docker 初探,實驗室中的運貨鯨
Docker 初探,實驗室中的運貨鯨
Ruoshi Ling
Más contenido relacionado
La actualidad más candente
Hybrid automation framework
Hybrid automation framework
doai tran
FirefoxOS and its use of Linux (a deep dive into Gonk architecture)
FirefoxOS and its use of Linux (a deep dive into Gonk architecture)
Aimee Maree Forsstrom
Docker introduction
Docker introduction
Phuc Nguyen
Installing and Running Postfix within a Docker Container
Installing and Running Postfix within a Docker Container
Docker, Inc.
Docker architecture-04-1
Docker architecture-04-1
Mohammadreza Amini
Cross platform app development with flutter
Cross platform app development with flutter
Hwan Jo
Report portal
Report portal
COMAQA.BY
Linux Audio Drivers. ALSA
Linux Audio Drivers. ALSA
GlobalLogic Ukraine
Introduction to Docker
Introduction to Docker
Pubudu Jayawardana
Installing and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command line
dotCloud
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Boni García
Git training v10
Git training v10
Skander Hamza
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
Edureka!
Flutter
Flutter
shreyash singh
Docker, LinuX Container
Docker, LinuX Container
Araf Karsh Hamid
Docker Introduction
Docker Introduction
Robert Reiz
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and Containers
Yajushi Srivastava
Docker 101 - Nov 2016
Docker 101 - Nov 2016
Docker, Inc.
introduction to flutter ppt - free download
introduction to flutter ppt - free download
RajatPalankar2
Web Development with Python and Django
Web Development with Python and Django
Michael Pirnat
La actualidad más candente
(20)
Hybrid automation framework
Hybrid automation framework
FirefoxOS and its use of Linux (a deep dive into Gonk architecture)
FirefoxOS and its use of Linux (a deep dive into Gonk architecture)
Docker introduction
Docker introduction
Installing and Running Postfix within a Docker Container
Installing and Running Postfix within a Docker Container
Docker architecture-04-1
Docker architecture-04-1
Cross platform app development with flutter
Cross platform app development with flutter
Report portal
Report portal
Linux Audio Drivers. ALSA
Linux Audio Drivers. ALSA
Introduction to Docker
Introduction to Docker
Installing and running Postfix within a docker container from the command line
Installing and running Postfix within a docker container from the command line
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Git training v10
Git training v10
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
Flutter
Flutter
Docker, LinuX Container
Docker, LinuX Container
Docker Introduction
Docker Introduction
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and Containers
Docker 101 - Nov 2016
Docker 101 - Nov 2016
introduction to flutter ppt - free download
introduction to flutter ppt - free download
Web Development with Python and Django
Web Development with Python and Django
Destacado
認識那條鯨魚 Docker 初探
認識那條鯨魚 Docker 初探
仲昀 王
Docker 初探,實驗室中的運貨鯨
Docker 初探,實驗室中的運貨鯨
Ruoshi Ling
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
Docker, Inc.
Docker home ted
Docker home ted
Layne Peng
Docker初识
Docker初识
hubugui
用 Go 語言打造微服務架構
用 Go 語言打造微服務架構
Bo-Yi Wu
Destacado
(6)
認識那條鯨魚 Docker 初探
認識那條鯨魚 Docker 初探
Docker 初探,實驗室中的運貨鯨
Docker 初探,實驗室中的運貨鯨
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
What's New in Docker 1.12 by Nishant Totla for Docker SF Meetup 08.03.16
Docker home ted
Docker home ted
Docker初识
Docker初识
用 Go 語言打造微服務架構
用 Go 語言打造微服務架構
Similar a Docker應用
Docker容器微服務 x WorkShop
Docker容器微服務 x WorkShop
Philip Zheng
Docker實務
Docker實務
國昭 張
docker intro
docker intro
koji lin
Docker
Docker
旭 張
Introduction to Docker
Introduction to Docker
Chris Chen
Docker open stack
Docker open stack
Guangya Liu
Docker基礎
Docker基礎
國昭 張
Docker Compose
Docker Compose
Miles Chou
Docker一期培训
Docker一期培训
青帅 常
Docker Build
Docker Build
Miles Chou
Rancher: 建立你的牧場艦隊
Rancher: 建立你的牧場艦隊
Miles Chou
Docker進階探討
Docker進階探討
國昭 張
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作
Philip Zheng
Gops2016 云端基于Docker的微服务与持续交付实践
Gops2016 云端基于Docker的微服务与持续交付实践
Li Yi
Docker
Docker
NCUDSC
20150604 docker 新手入門
20150604 docker 新手入門
azole Lai
Ruby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for Ubuntu
MarsZ Chen
Docker基礎
Docker基礎
Perry Tsai
Docker集群管理 工具篇
Docker集群管理 工具篇
Guangya Liu
Docker 最佳实践
Docker 最佳实践
YuLing Liu
Similar a Docker應用
(20)
Docker容器微服務 x WorkShop
Docker容器微服務 x WorkShop
Docker實務
Docker實務
docker intro
docker intro
Docker
Docker
Introduction to Docker
Introduction to Docker
Docker open stack
Docker open stack
Docker基礎
Docker基礎
Docker Compose
Docker Compose
Docker一期培训
Docker一期培训
Docker Build
Docker Build
Rancher: 建立你的牧場艦隊
Rancher: 建立你的牧場艦隊
Docker進階探討
Docker進階探討
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作
Gops2016 云端基于Docker的微服务与持续交付实践
Gops2016 云端基于Docker的微服务与持续交付实践
Docker
Docker
20150604 docker 新手入門
20150604 docker 新手入門
Ruby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for Ubuntu
Docker基礎
Docker基礎
Docker集群管理 工具篇
Docker集群管理 工具篇
Docker 最佳实践
Docker 最佳实践
Más de Jui An Huang (黃瑞安)
Golang PostgreSQL Libraries Comparasion With Wireshark
Golang PostgreSQL Libraries Comparasion With Wireshark
Jui An Huang (黃瑞安)
Scaling Offline Database Usage On GCP @ Dcard
Scaling Offline Database Usage On GCP @ Dcard
Jui An Huang (黃瑞安)
Www 2017第二次新生訓練:系統設計
Www 2017第二次新生訓練:系統設計
Jui An Huang (黃瑞安)
Www 2017第一次新生訓練:系統分析
Www 2017第一次新生訓練:系統分析
Jui An Huang (黃瑞安)
Www 2017第三次新生訓練:transaction, migration, worker
Www 2017第三次新生訓練:transaction, migration, worker
Jui An Huang (黃瑞安)
Elasitcsearch + Logstash + Kibana 日誌監控
Elasitcsearch + Logstash + Kibana 日誌監控
Jui An Huang (黃瑞安)
Elasticsearch 簡介
Elasticsearch 簡介
Jui An Huang (黃瑞安)
Git 版本控制 (使用教學)
Git 版本控制 (使用教學)
Jui An Huang (黃瑞安)
Más de Jui An Huang (黃瑞安)
(8)
Golang PostgreSQL Libraries Comparasion With Wireshark
Golang PostgreSQL Libraries Comparasion With Wireshark
Scaling Offline Database Usage On GCP @ Dcard
Scaling Offline Database Usage On GCP @ Dcard
Www 2017第二次新生訓練:系統設計
Www 2017第二次新生訓練:系統設計
Www 2017第一次新生訓練:系統分析
Www 2017第一次新生訓練:系統分析
Www 2017第三次新生訓練:transaction, migration, worker
Www 2017第三次新生訓練:transaction, migration, worker
Elasitcsearch + Logstash + Kibana 日誌監控
Elasitcsearch + Logstash + Kibana 日誌監控
Elasticsearch 簡介
Elasticsearch 簡介
Git 版本控制 (使用教學)
Git 版本控制 (使用教學)
Docker應用
1.
Docker.io 運用 Docker 快速部署 資工三
黃瑞安 rueiancsie@gmail.com 2014/09/29
2.
Docker 是什麼? Docker 是一個部署工具。它用
Linux 內核的資源 分離機制建立獨立的 Docker Container 來提供 一個抽象層,讓你可以下幾個指令,透過幾個 Container 就將你的服務、應用部署起來。 例如說要部署一個 web app,你可能只需要兩個 Container ,一個跑 psql ,一個跑 nginx,共需要 兩個指令。
3.
Docker 架構 Docker 是
client-server 的架構。 Docker client 負責與 server 端的 Docker deamon 溝通,下達像是 docker pull、docker run 等指令。一般而言,Docker client 與 Docker deamon 是在同一台機器上面。
4.
Docker 架構
5.
Docker 如何使用? Docker 有三個重要的元件,了解他們對於使用 Docker
會有大的幫助。 ● Docker images ● Docker containers ● Docker registries
6.
Docker Images & Containers Docker
image 是一個用來產生 Container 的樣 板。例如說一個 image 裡面可能會含有一個 ubuntu + Apache + web app,你可以用這個 image 建立出 Container ,並讓它執行 Apache, 這樣就將 web app 部署好了。 Docker 還提供 commit 指令讓你可以基於現有 的 Container 來更新或建立新的 image。
7.
Docker Registries Docker Registries
是用來存放 images 的倉庫。 在進行 docker pull 的時候,docker 就會從指定 的 registry 將 image 下載下來。 預設的公用 Registry 就是 Docker Hub,提供如 Github 般的功能。若想自行建立私有 registry 可 以參考 Docker API 文件。
8.
Docker Hub Docker Hub
就像如 Github 一般,是個具有社交 功能的公共 image 倉庫。 你可以方便的透過 Docker Hub 下載 image 來使 用或是基於它們來製作你自己的 image,也可以 將你製作好的 image 推上去分享給別人。
9.
Docker & Docker
Hub 1. 與DockerHub詢問 image 在哪裡。 2. DockerHub回覆說在 Registry A。 3. 與Registry A請求該image。 4. Registry A詢問DockerHub該使用者 可否下載此image。 5. DockerHub將回覆 true or false。 6. 若通過驗證,則開始下載 image。
10.
安裝 Docker 由於 Docker
需要 Linux kernal,在非 Linux 系統 無法使用。Docker 官方提供了 Boot2Docker 這 個基於 VirtualBox 的小工具可以省去安裝虛擬機 的過程。其他如 ubuntu 只需要 apt-get install docker.io 即可安裝。 不過我建議若要在非 Linux 平台上面使用,還是 自己灌一個完整的 Linux 虛擬機,方便使用虛擬 機的資料夾共享功能。
11.
Docker 常用指令 docker pull docker
push docker commit docker diff docker run docker ps docker images docker build ... 下載 image 上傳 image 由 container 製作新的 image 觀看 container 的改變 創建 container 並運行 查看目前的 containers 查看目前的 images 由 Dockerfile 製作新的 image
12.
用 Docker 部署
Rails App 以 docker 提供的 rails, postgres image 為例 (https://registry.hub.docker.com/_/rails/) (https://registry.hub.docker.com/_/postgres/) 1. 首先運行 postgres 資料庫: $ docker run --name mydb -d postgres --name 參數是將此 container 命名為 mydb -d 參數是讓此 container 在背景執行
13.
用 Docker 部署
Rails App 2. 建立你自己的 Rails image: 2.1. 修改你的 config/database.yml 如下 2.2. ... PG_PORT_5432_TCP_ADDR 環境變數將會來自於 mydb container,至於 資料庫的帳號密碼,可從 postgres image 的 Dockerfile 取得。 development: adapter: postgresql database: myapp host: <%= ENV[“PG_PORT_5432_TCP_ADDR”] %> username: postgres password: ‘’
14.
用 Docker 部署
Rails App 2. 建立你自己的 Rails image: 2.1. ... 2.2. 在 app 根目錄下面建立 Dockerfile ,內容僅一行: FROM rails:onbuild 2.3. 接著下指令建立 image: $ docker build -t myapp-img . -t 參數用來將建立的 image 命名,
15.
用 Docker 部署
Rails App 3. 開始部署你的 Rails App: 3.1. 第一次先做 migration: $docker run --rm --link mydb:pg myapp-img sh -c “rake db:create & rake db:migrate” 3.2. … --rm 參數是當這個 container 結束時,就將這個 container 刪除。 --link 參數指定這個 container 要與哪個 container 連接,”:” 後面的是 alias 別名,會將連接進來的環境變數加上別名當作前綴。例如先前更 改 config/database.yml 中的 “PG_PORT_5432_TCP_ADDR”
16.
用 Docker 部署
Rails App 3. 開始部署你的 Rails image: 3.1. ... 3.2. 接著啟動 rails server: $docker run --name myapp -d -p 80:3000 --link mydb:pg myapp-img -p 參數這裡是將 container 的 3000 port 對應到 host 的 80 port
17.
用 Docker 部署
Rails App 4. 部署完成,瀏覽 http://localhost 即可以看見你 的 rails app ! 5. 若要將 postgres container 的內容備份出來 $ docker run --rm --volumes-from mydb -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /var/lib/postgresql/data --volumes-from 參數是將 mydb container 的 volume 掛入 -v 參數是在這個 container 創建一個在 /backup 的 volumn,並將 host 的當前目錄 $(pwd) 掛入該 volumn /var/lib/postgresql/data 這個位置可在 postgresql image 的 Dockerfile 找到
18.
用 Docker 部署
Rails App 6. 用類似的方法還原資料庫 $ docker run --name mydb2 -d postgres $ docker run --rm --volumes-from mydb2 -v $(pwd):/backup ubuntu tar xvf /backup/backup.tar 除了可以還原到同一個 container 之外,我們也可以再創建一個 postgres container (mydb2),再將原本的 container 資料複製進去。 可以利用這技巧去做備份、資料遷移、測試等工作。
19.
用 Vagrant +
Docker 建構 Rails 開發環境 Vagrant 1.6 提供了 Docker 可以作為 Provider 和 Provisioner,用來建構開發環境相當方便,尤其是在 OSX 與 Windows,因為 Vagrant 可以方便解決資料夾 共享還有網路的問題。
20.
用 Vagrant +
Docker 建構 Rails 開發環境 在 Windows 與 OSX 上面使用 docker provider 的話, Vagrant 會自動開一台 VM 來運行 docker,可以完全取 代 boot2docker 工具。 若在 Linux 上使用,Vagrant 則會使用系統內的 docker, 不用透過 host vm。 這樣一來利用 docker,可以讓各個平台都有相同的開發 環境,又比開完整的 VM 省資源。
21.
用 Vagrant +
Docker 建構 Rails 開發環境 在專案根目錄創建 Dockerfile 如下: 這次我們使用 phusion/passenger-ruby21 作為 base image,最主要是因 為它有支援 ssh,在開發上會比較方便。ssh 用的 private key 可在此找到 https://github.com/phusion/baseimage-docker#login_ssh FROM phusion/passenger-ruby21:0.9.12 RUN apt-get update && apt-get install -y nodejs --no-install-recommends && rm -rf /var/lib/apt/lists/* EXPOSE 3000
22.
用 Vagrant +
Docker 建構 Rails 開發環境 在 Windows 和 OSX,必須額外為 Vagrant 創建的 docker host vm 設定 port forward 與 synced_folder,才能用來作為開發環境。 專案根目錄下的 Vagrantfile.dockerhost 內容如下: Vagrant.configure("2") do |config| config.vm.box = "yungsang/boot2docker" config.vm.provision "docker" config.vm.synced_folder ".", "/app" config.vm.network "forwarded_port", guest: 3000, host: 3000 end
23.
用 Vagrant +
Docker 建構 Rails 開發環境 在專案根目錄準備 Vagrantfile 如下: Vagrant.configure(“2”) do |config| config.vm.define "app" do |v| v.vm.provider "docker" do |d| d.build_dir = "." d.cmd = ["/sbin/my_init", "--enable-insecure-key"] d.ports = ["3000:3000"] d.volumes = ["/app/:/app"] d.has_ssh = true d.vagrant_vagrantfile = "Vagrantfile.dockerhost" end v.ssh.username = "root" v.ssh.private_key_path ="phusion.key" end end
24.
用 Vagrant +
Docker 建構 Rails 開發環境 Vagrant 的 docker provider 和 provisioner 基本上就是 docker cli 的包 裝。前一頁面這個 Vagrantfile 其實就是先根據當前目錄的 Dockerfile 創 建 image,再透過給定的參數運行起來,與下面指令大致相同: $ docker run -p 3000:3000 -v /app/:/app image /sbin/my_init --enable-insecure-key 除了這些之外,還有一些其他參數: d.has_ssh 若為 true,則讓 vagrant ssh 可運作 d.vagrant_vagrantfile 指定 Vagrantfile 來創建 host vm v.ssh.username 指定 ssh 登入用戶名 v.ssh.private_key_path 指定 ssh 登入用的 private key
25.
用 Vagrant +
Docker 建構 Rails 開發環境 準備好這些 Dockerfile 還有 Vagrantfile 之後,可以執行 $ vagrant up app --provider=docker 來創建 container。 完成後可以用 $ vagrant ssh app 進入該 container 去運行 bundle、rails server 或其他 rake tasks。 其他管理操作指令: $ vagrant global-status 查看目前所有 vagrant vm(含 host vm) 的情況 $ vagrant status 查看當前 Vagrantfile 環境的情況 $ vagrant destroy 刪除指定 vagrant vm $ vagrant docker-logs 查看指定 docker container 的 log $ vagrant docker-run 運行指定的 docker image
26.
參考資料 ● Docker Tutorial ●
About Docker ● Docker User Guide ● Docker CLI Reference ● Dockerfile Reference ● Best Practices for Writing Dockerfiles ● Dockerizing PostgreSQL ● Vagrant: Docker-Based Development Environments ● Vagrant: Docker Configuration ● Phusion Passenger-Docker ● Yungsang Boo2docker Image
Descargar ahora