阿里云部署Docker(5)----管理和公布您的镜像
出到這節,我在百度搜索了一下“阿里云部署Docker”,突然發現怎么會有人跟我寫的一樣呢?哦,原來是其它博客系統的爬蟲來抓取,然后也不會寫轉載自什么什么的。所以,我最終明確為什么那些大咖的文章總會在文章的開頭寫明,轉載請注明原創來自xxx的。恩。get it,從這篇開始,我也要這樣了。
本文歡迎轉載,但要尊重本人勞動成果,轉載注明轉自“http://blog.csdn.net/minimicall/”?http://blog.csdn.net/minimicall/article/details/40147207
對阿里云里面部署Docker,我的之前的文章有:
第一篇,安裝篇:http://blog.csdn.net/minimicall/article/details/40108305
第二篇,依然是安裝:http://blog.csdn.net/minimicall/article/details/40119177
第三篇,基礎指令學習:http://blog.csdn.net/minimicall/article/details/40143061
第四篇,容器的使用:http://blog.csdn.net/minimicall/article/details/40144719
今天,我們要進一步解說,
管理本地鏡像
創建基礎鏡像
上傳公布鏡像
Listing images on the host
我們首先通過 docker images來查看一下我們本地有什么鏡像。 root@iZ28ikebrg6Z:~# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu utopic 2185fd50e2ca 2 days ago 237.2 MB ubuntu 14.10 2185fd50e2ca 2 days ago 237.2 MB ubuntu trusty 9cbaf023786c 2 days ago 192.8 MB ubuntu 14.04 9cbaf023786c 2 days ago 192.8 MB ubuntu 14.04.1 9cbaf023786c 2 days ago 192.8 MB ubuntu latest 9cbaf023786c 2 days ago 192.8 MB ubuntu 12.04.5 a9561eb1b190 2 days ago 120.2 MB ubuntu precise a9561eb1b190 2 days ago 120.2 MB ubuntu 12.04 a9561eb1b190 2 days ago 120.2 MB centos latest 87e5b6b3ccc1 2 weeks ago 224 MB ubuntu 12.10 c5881f11ded9 3 months ago 172.2 MB ubuntu quantal c5881f11ded9 3 months ago 172.2 MB ubuntu 13.04 463ff6be4238 3 months ago 169.4 MB ubuntu raring 463ff6be4238 3 months ago 169.4 MB ubuntu saucy 195eb90b5349 3 months ago 184.7 MB ubuntu 13.10 195eb90b5349 3 months ago 184.7 MB training/webapp latest 31fa814ba25a 4 months ago 278.8 MB ubuntu lucid 3db9c44f4520 5 months ago 183 MB ubuntu 10.04 3db9c44f4520 5 months ago 183 MB能夠看到,我在之前的教程里面拉取了兩個一個是ubuntu,一個是training/webapp。當中ubuntu,docker給我拉取了那么多變種回來。上面的輸出有一列叫“TAG”,記得我們執行的時候會有"docker run ubuntu:14.04 /bin/bash 么 !就是依據TAG來精確的指定我們想要執行的那個ubuntu,否則docker會自作聰明的執行TAG為“latest”的那個鏡像。Getting a new image
Finding images
搜索一個鏡像,你能夠選擇去docker hub的站點搜索,也能夠選擇在本地用命令行的方式進行。例如以下:
root@iZ28ikebrg6Z:~# docker search redmine NAME DESCRIPTION STARS OFFICIAL AUTOMATED sameersbn/redmine 40 [OK] webts/redmine Self contained Redmine 2.4 install on Cent... 2 triangle/redmine-plugin-dev Redmine 2.4.1 on ruby 2.0 aimed at plugin ... 1 [OK] oasis/redmine-git 1 melopos/redmine 1 [OK] turnkeylinux/redmine-13.0 TurnKey Redmine - Integrated SCM & Project... 1 sherkenh/redmine 0 oasis/redmine 0 bernigaud/redmine Redmine for my server HAL Forked from same... 0 eprecise/redmine 0 hogefoobar/redmine 0 mattuso/redmine_nginx 0 [OK] mattuso/redmine_mysql 0 [OK] aofox5152/redmine 0 chonglou/redmine remine+mysql+nginx 0 laughk/redmine 0 krickwix/redmine 0 bazitov/redmine 0 sasasin/redmine-scrum ALMinium on CentOS 6, with SSH server. 0 yjkim/apache-redmine 0 sosyco/redmine-sqlite-debian Tryout/GetAndRun Redmine 2.5.1/sqlitel/De... 0 eternnoir/redminebot 0 [OK] sosyco/redmine-mysql-debian Tryout/GetAndRun Redmine 2.5.1/mysql/Debi... 0 hiromiso/redmine2.4 redmine + mysql 0 tmtkd/redminetest Sep. 1st, 2014 test of redmine/docker 0 pvdvreede/redminedev Installation of ruby 2.0.0-p247 and others 0 madmaze/ubunturedmine quick ubuntu 12.04 image with Redmine on s... 0 shaftoe/new_redmine WARNING: old legacy Redmine, not usable fo... 0 mattuso/redmine_unicorn 0 [OK] vpetersson/redmine 0 [OK] miraitechno/redmine 0 [OK] pnelson/redmine 0 [OK] padelt/redmine 0 [OK] binaryphile/redmine Reusable, general-purpose Redmine instance... 0我們搜索了一下redmine,這是個項目管理的服務。上面的列 有,名字,描寫敘述,星級(越流行評分越高,提供參考),是否有官方維護,是否自己主動化,這點我不是非常能理解,我也不敢誤人子弟。所以還是引用官網的那句話,各位看官自己理解
“Official repositories are built and maintained by the?Stackbrew?project, and Automated repositories are?Automated Builds?that allow you to validate the source and content of an image.”
選一個pull下來即可了。
Building an image from a?Dockerfile
通過Dockerfile來構建一個鏡像。用vim寫一個Dockerfile,內如例如以下: #This is a comment FROM ubuntu:14.04 MAINTAINER zengjinlong <470910357@qq.com> RUN apt-get update && apt-get install -y ruby ruby-dev RUN gem install sinatra命令都是大寫,FROM表示它的源是什么,比如我們這個是給予Ubuntu:14.04的,MAINTANER是維護人員,比方說我,小曾,賣下萌。
RUN表示運行指令。
好,運行上述Dockerfile。
root@iZ28ikebrg6Z:~/docker# docker build -t="zengjinlong/sinatra:v2" . Sending build context to Docker daemon 2.56 kB Sending build context to Docker daemon Step 0 : FROM ubuntu:14.04---> 9cbaf023786c Step 1 : MAINTAINER zengjinlong <470910357@qq.com>---> Running in c5674e71d7e4---> 224b40d4b89f Removing intermediate container c5674e71d7e4 Step 2 : RUN apt-get update && apt-get install -y ruby ruby-dev---> Running in 5d6373cb79e6 Ign http://archive.ubuntu.com trusty InRelease Ign http://archive.ubuntu.com trusty-updates InRelease Ign http://archive.ubuntu.com trusty-security InRelease Ign http://archive.ubuntu.com trusty-proposed InRelease Get:1 http://archive.ubuntu.com trusty Release.gpg [933 B] Get:2 http://archive.ubuntu.com trusty-updates Release.gpg [933 B] Get:3 http://archive.ubuntu.com trusty-security Release.gpg [933 B] Get:4 http://archive.ubuntu.com trusty-proposed Release.gpg [933 B] Get:5 http://archive.ubuntu.com trusty Release [58.5 kB] Get:6 http://archive.ubuntu.com trusty-updates Release [59.7 kB] Get:7 http://archive.ubuntu.com trusty-security Release [59.7 kB] Get:8 http://archive.ubuntu.com trusty-proposed Release [110 kB] Get:9 http://archive.ubuntu.com trusty/main Sources [1335 kB]會耗費比較長的時間。
我們技術下一步的學習。
標記一個image
docker tag 5db5f8471261 ouruser/sinatra:develroot@iZ28ikebrg6Z:~/docker# docker tag 224b40d4b89f zengjinlong/sinatra:v3結果顯示一下,
輸出:
root@iZ28ikebrg6Z:~/docker# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE <strong><span style="color:#ff0000;">zengjinlong/sinatra v3 </span></strong> 224b40d4b89f 13 minutes ago 192.8 MB ubuntu 14.10 2185fd50e2ca 2 days ago 237.2 MB ubuntu utopic 2185fd50e2ca 2 days ago 237.2 MB ubuntu trusty 9cbaf023786c 2 days ago 192.8 MB ubuntu latest 9cbaf023786c 2 days ago 192.8 MB ubuntu 14.04.1 9cbaf023786c 2 days ago 192.8 MB ubuntu 14.04 9cbaf023786c 2 days ago 192.8 MB ubuntu precise a9561eb1b190 2 days ago 120.2 MB ubuntu 12.04.5 a9561eb1b190 2 days ago 120.2 MB ubuntu 12.04 a9561eb1b190 2 days ago 120.2 MB centos centos5 504a65221a38 2 weeks ago 467.1 MB centos centos6 68edf809afe7 2 weeks ago 212.7 MB centos centos7 87e5b6b3ccc1 2 weeks ago 224 MB centos latest 87e5b6b3ccc1 2 weeks ago 224 MB ubuntu quantal c5881f11ded9 3 months ago 172.2 MB ubuntu 12.10 c5881f11ded9 3 months ago 172.2 MB ubuntu 13.04 463ff6be4238 3 months ago 169.4 MB ubuntu raring 463ff6be4238 3 months ago 169.4 MB ubuntu saucy 195eb90b5349 3 months ago 184.7 MB ubuntu 13.10 195eb90b5349 3 months ago 184.7 MB training/webapp latest 31fa814ba25a 4 months ago 278.8 MB ubuntu 10.04 3db9c44f4520 5 months ago 183 MB ubuntu lucid 3db9c44f4520 5 months ago 183 MB上傳我們的鏡像到docker hub里面。 root@iZ28ikebrg6Z:~/docker# docker push zengjinlong/sinatra The push refers to a repository [zengjinlong/sinatra] (len: 1) Sending image list ^Croot@iZ28ikebrg6Z:~/docker#
演示一下就OK,不是非常想在這里浪費時間。
刪除本地鏡像,由于畢竟占地方把。
root@iZ28ikebrg6Z:~/docker# docker rmi centos Untagged: centos:latest root@iZ28ikebrg6Z:~/docker# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE zengjinlong/sinatra v3 224b40d4b89f 18 minutes ago 192.8 MB ubuntu 14.10 2185fd50e2ca 2 days ago 237.2 MB ubuntu utopic 2185fd50e2ca 2 days ago 237.2 MB ubuntu 14.04 9cbaf023786c 2 days ago 192.8 MB ubuntu latest 9cbaf023786c 2 days ago 192.8 MB ubuntu trusty 9cbaf023786c 2 days ago 192.8 MB ubuntu 14.04.1 9cbaf023786c 2 days ago 192.8 MB ubuntu 12.04.5 a9561eb1b190 2 days ago 120.2 MB ubuntu 12.04 a9561eb1b190 2 days ago 120.2 MB ubuntu precise a9561eb1b190 2 days ago 120.2 MB centos centos5 504a65221a38 2 weeks ago 467.1 MB centos centos6 68edf809afe7 2 weeks ago 212.7 MB centos centos7 87e5b6b3ccc1 2 weeks ago 224 MB ubuntu 12.10 c5881f11ded9 3 months ago 172.2 MB ubuntu quantal c5881f11ded9 3 months ago 172.2 MB ubuntu raring 463ff6be4238 3 months ago 169.4 MB ubuntu 13.04 463ff6be4238 3 months ago 169.4 MB ubuntu saucy 195eb90b5349 3 months ago 184.7 MB ubuntu 13.10 195eb90b5349 3 months ago 184.7 MB training/webapp latest 31fa814ba25a 4 months ago 278.8 MB ubuntu lucid 3db9c44f4520 5 months ago 183 MB ubuntu 10.04 3db9c44f4520 5 months ago 183 MB root@iZ28ikebrg6Z:~/docker# docker rmi centos:* Error response from daemon: No such image: centos:* 2014/10/16 15:38:58 Error: failed to remove one or more images root@iZ28ikebrg6Z:~/docker# docker rmi centos Error response from daemon: No such image: centos:latest 2014/10/16 15:39:03 Error: failed to remove one or more images root@iZ28ikebrg6Z:~/docker#看來出了latest能夠直接刪除,其它的須要帶上TAG才干指定刪除。
好今天到這里。
轉載于:https://www.cnblogs.com/blfshiye/p/4056824.html
總結
以上是生活随笔為你收集整理的阿里云部署Docker(5)----管理和公布您的镜像的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: hyper虚拟机下对centos进行动态
- 下一篇: codeforces 483B Fri