Docker Hub工作流程-Docker for Web Developers(6)

Docker GitHub 雲計算 Ubuntu 科技優家 2017-06-22

在Github上創建項目倉庫

和創建其他Github項目一樣,在Github創建一個倉庫,然後在倉庫裡面增加一個dockerfile,然後提交併推送到Github上。

Dockerfile內容如下:

#FROM - Image to start building on.
FROM ubuntu:14.04

#MAINTAINER - Identifies the maintainer of the dockerfile.
MAINTAINER [email protected]

#RUN - Runs a command in the container
RUN echo "Hello World" > /root/hello_world.txt

#CMD - Identifies the command that should be used by default when running the image as a container.
CMD ["cat", "/root/hello_world.txt"]

在Docker Hub上構建工作流

步驟1:註冊Dockerhub並登錄。

步驟2:基於Github倉庫創建自動化構建

Docker Hub工作流程-Docker for Web Developers(6)

選擇Github

Docker Hub工作流程-Docker for Web Developers(6)

步驟3:查看Build Settings

Docker Hub工作流程-Docker for Web Developers(6)

步驟4:查看Build Details

Docker Hub工作流程-Docker for Web Developers(6)

構建和迭代我們的項目

本地修改Dockerfile文件,提交併推動到Github上。

驗證上述發生的變化。

獲取鏡像,並運行,查看內容是否變化。

docker pull bage88/simple-dockerfile

運行Docker鏡像

docker run 
Docker Hub工作流程-Docker for Web Developers(6)

因為Docker Hub訪問速度問題,而且企業內部開發的代碼都需要打包成私有的鏡像。所以Docker Hub適合開源的小型項目。

對於企業內部來說,可以使用國內雲計算廠商提供的鏡像服務,也可以在企業內部搭建。

相關推薦

推薦中...