標籤:style blog http color os io art div
本文計劃:
- 一.安裝Docker(Centos)
- 二.註冊Docker官網帳號
- 三.下載基礎centos鏡像,安裝需要的軟體和環境後,push到自己的repository
一.安裝Docker(Centos)
在https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F 中選擇自己的epel源.
接著,安裝docker-io:
$ sudo yum install docker-io
啟動Docker daemon:
$ sudo service docker start
將Docker設定成開機啟動:
$ sudo chkconfig docker on
下載最新的基礎centos:
$ sudo docker pull centos:latest
測試centos是否可以運行成功:
$ sudo docker images centos
二.註冊Docker官網帳號
註冊自己的Docker倉庫帳號,作用相當於開闢一個image倉庫,等同於GitHub:
https://hub.docker.com/account/signup/
三.下載別人的image,作出修改後,push到自己的repository
下面舉個例子,我在image:centos中安裝wget後,提交到自己的repository:
進入操作介面
[[email protected]113058 ~]# sudo docker run -i -t centos /bin/bashbash-4.2#
安裝wget,安裝結束後退出:
bash-4.2# yum install wgetbash-4.2#exit
查看自己的修改記錄:
[[email protected]113058 ~]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES5f962b864221 centos:latest /bin/bash 2 minutes ago Exited (0) 42 seconds ago goofy_mcclintock 36f07f440c17 centos:latest /bin/bash 38 minutes ago Exited (0) 35 minutes ago boring_kowalevski 38e000fbee87 centos:latest /bin/bash 41 minutes ago Exited (127) 40 minutes ago sleepy_yonath
可以看到,最近提交的是5f962b864221,這個即是我們安裝了wget的image,將它push到自己的repository,有三個步驟:
[[email protected]113058 ~]# docker commit 5f962b864221 alexknight/centos-wget
其中,alexknight是自己在倉庫裡開闢的空間名,接下來是登入自己的帳號
[[email protected]113058 ~]# docker login -u "第二步註冊的名字" -p "passwd" -e "郵箱地址"
登入成功後,push自己的提交
[[email protected]113058 ~]# docker push alexknight/centos-wget
當在介面看到centos-wget時,操作成功。
把自己提交的centos-wget下載:
[[email protected]113058 ~]# docker pull alexknight/centos-wgetPulling repository alexknight/centos-wgetaa194d98cc9e: Download complete 511136ea3c5a: Download complete 34e94e67e63a: Download complete 1a7dc42f78ba: Download complete
再次進入到自己的centos-wget這個版本進行持續提交時:
[[email protected]113058 ~]#sudo docker run -i -t alexknight/centos-wget /bin/bash