博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
阿里云部署Docker(5)----管理和公布您的镜像
阅读量:5882 次
发布时间:2019-06-19

本文共 13253 字,大约阅读时间需要 44 分钟。

出到这节,我在百度搜索了一下“阿里云部署Docker”,突然发现怎么会有人跟我写的一样呢?哦,原来是其它博客系统的爬虫来抓取,然后也不会写转载自什么什么的。所以,我最终明确为什么那些大咖的文章总会在文章的开头写明,转载请注明原创来自xxx的。恩。get it,从这篇開始,我也要这样了。

本文欢迎转载,但要尊重本人劳动成果,转载注明转自“” 

对阿里云里面部署Docker,我的之前的文章有:

第一篇,安装篇:

第二篇,依然是安装:

第三篇,基础指令学习:

第四篇,容器的使用:

今天,我们要进一步解说,

管理本地镜像

创建基础镜像

上传公布镜像

Listing images on the host

我们首先通过 docker images来查看一下我们本地有什么镜像。

root@iZ28ikebrg6Z:~# docker imagesREPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZEubuntu              utopic              2185fd50e2ca        2 days ago          237.2 MBubuntu              14.10               2185fd50e2ca        2 days ago          237.2 MBubuntu              trusty              9cbaf023786c        2 days ago          192.8 MBubuntu              14.04               9cbaf023786c        2 days ago          192.8 MBubuntu              14.04.1             9cbaf023786c        2 days ago          192.8 MBubuntu              latest              9cbaf023786c        2 days ago          192.8 MBubuntu              12.04.5             a9561eb1b190        2 days ago          120.2 MBubuntu              precise             a9561eb1b190        2 days ago          120.2 MBubuntu              12.04               a9561eb1b190        2 days ago          120.2 MBcentos              latest              87e5b6b3ccc1        2 weeks ago         224 MBubuntu              12.10               c5881f11ded9        3 months ago        172.2 MBubuntu              quantal             c5881f11ded9        3 months ago        172.2 MBubuntu              13.04               463ff6be4238        3 months ago        169.4 MBubuntu              raring              463ff6be4238        3 months ago        169.4 MBubuntu              saucy               195eb90b5349        3 months ago        184.7 MBubuntu              13.10               195eb90b5349        3 months ago        184.7 MBtraining/webapp     latest              31fa814ba25a        4 months ago        278.8 MBubuntu              lucid               3db9c44f4520        5 months ago        183 MBubuntu              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

怎样获取一个新的镜像。我们知道当我们执行一个镜像的时候,假设这个镜像比如centos在本地没有,docker会自己主动的去远端库查询和下载。可是这样的暂时的下载明显是费时间的,我们能够不能够提前去下载呢?能够,使用docker pull拉取指令。

root@iZ28ikebrg6Z:~# docker pull centosPulling repository centos^Croot@iZ28ikebrg6Z:~# ^C
你看,它会去拉取,只是我中断了,由于我不须要,我的阿里云存储非常金贵的。

Finding images

搜索一个镜像,你能够选择去docker hub的站点搜索,也能够选择在本地用命令行的方式进行。

例如以下:

root@iZ28ikebrg6Z:~# docker search redmineNAME                           DESCRIPTION                                     STARS     OFFICIAL   AUTOMATEDsameersbn/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  project, and Automated repositories are  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 commentFROM ubuntu:14.04MAINTAINER zengjinlong <470910357@qq.com>RUN apt-get update && apt-get install -y ruby ruby-devRUN 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 kBSending build context to Docker daemon Step 0 : FROM ubuntu:14.04 ---> 9cbaf023786cStep 1 : MAINTAINER zengjinlong <470910357@qq.com> ---> Running in c5674e71d7e4 ---> 224b40d4b89fRemoving intermediate container c5674e71d7e4Step 2 : RUN apt-get update && apt-get install -y ruby ruby-dev ---> Running in 5d6373cb79e6Ign http://archive.ubuntu.com trusty InReleaseIgn http://archive.ubuntu.com trusty-updates InReleaseIgn http://archive.ubuntu.com trusty-security InReleaseIgn http://archive.ubuntu.com trusty-proposed InReleaseGet: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:devel
root@iZ28ikebrg6Z:~/docker# docker tag   224b40d4b89f  zengjinlong/sinatra:v3
结果显示一下,

输出:

root@iZ28ikebrg6Z:~/docker# docker imagesREPOSITORY            TAG                 IMAGE ID            CREATED             VIRTUAL SIZEzengjinlong/sinatra   v3                  224b40d4b89f        13 minutes ago      192.8 MBubuntu                14.10               2185fd50e2ca        2 days ago          237.2 MBubuntu                utopic              2185fd50e2ca        2 days ago          237.2 MBubuntu                trusty              9cbaf023786c        2 days ago          192.8 MBubuntu                latest              9cbaf023786c        2 days ago          192.8 MBubuntu                14.04.1             9cbaf023786c        2 days ago          192.8 MBubuntu                14.04               9cbaf023786c        2 days ago          192.8 MBubuntu                precise             a9561eb1b190        2 days ago          120.2 MBubuntu                12.04.5             a9561eb1b190        2 days ago          120.2 MBubuntu                12.04               a9561eb1b190        2 days ago          120.2 MBcentos                centos5             504a65221a38        2 weeks ago         467.1 MBcentos                centos6             68edf809afe7        2 weeks ago         212.7 MBcentos                centos7             87e5b6b3ccc1        2 weeks ago         224 MBcentos                latest              87e5b6b3ccc1        2 weeks ago         224 MBubuntu                quantal             c5881f11ded9        3 months ago        172.2 MBubuntu                12.10               c5881f11ded9        3 months ago        172.2 MBubuntu                13.04               463ff6be4238        3 months ago        169.4 MBubuntu                raring              463ff6be4238        3 months ago        169.4 MBubuntu                saucy               195eb90b5349        3 months ago        184.7 MBubuntu                13.10               195eb90b5349        3 months ago        184.7 MBtraining/webapp       latest              31fa814ba25a        4 months ago        278.8 MBubuntu                10.04               3db9c44f4520        5 months ago        183 MBubuntu                lucid               3db9c44f4520        5 months ago        183 MB
上传我们的镜像到docker hub里面。

root@iZ28ikebrg6Z:~/docker# docker push zengjinlong/sinatraThe push refers to a repository [zengjinlong/sinatra] (len: 1)Sending image list^Croot@iZ28ikebrg6Z:~/docker#
演示一下就OK,不是非常想在这里浪费时间。

删除本地镜像,由于毕竟占地方把。

root@iZ28ikebrg6Z:~/docker# docker rmi centosUntagged: centos:latestroot@iZ28ikebrg6Z:~/docker# docker imagesREPOSITORY            TAG                 IMAGE ID            CREATED             VIRTUAL SIZEzengjinlong/sinatra   v3                  224b40d4b89f        18 minutes ago      192.8 MBubuntu                14.10               2185fd50e2ca        2 days ago          237.2 MBubuntu                utopic              2185fd50e2ca        2 days ago          237.2 MBubuntu                14.04               9cbaf023786c        2 days ago          192.8 MBubuntu                latest              9cbaf023786c        2 days ago          192.8 MBubuntu                trusty              9cbaf023786c        2 days ago          192.8 MBubuntu                14.04.1             9cbaf023786c        2 days ago          192.8 MBubuntu                12.04.5             a9561eb1b190        2 days ago          120.2 MBubuntu                12.04               a9561eb1b190        2 days ago          120.2 MBubuntu                precise             a9561eb1b190        2 days ago          120.2 MBcentos                centos5             504a65221a38        2 weeks ago         467.1 MBcentos                centos6             68edf809afe7        2 weeks ago         212.7 MBcentos                centos7             87e5b6b3ccc1        2 weeks ago         224 MBubuntu                12.10               c5881f11ded9        3 months ago        172.2 MBubuntu                quantal             c5881f11ded9        3 months ago        172.2 MBubuntu                raring              463ff6be4238        3 months ago        169.4 MBubuntu                13.04               463ff6be4238        3 months ago        169.4 MBubuntu                saucy               195eb90b5349        3 months ago        184.7 MBubuntu                13.10               195eb90b5349        3 months ago        184.7 MBtraining/webapp       latest              31fa814ba25a        4 months ago        278.8 MBubuntu                lucid               3db9c44f4520        5 months ago        183 MBubuntu                10.04               3db9c44f4520        5 months ago        183 MBroot@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 imagesroot@iZ28ikebrg6Z:~/docker# docker rmi centosError response from daemon: No such image: centos:latest2014/10/16 15:39:03 Error: failed to remove one or more imagesroot@iZ28ikebrg6Z:~/docker#
看来出了latest能够直接删除,其它的须要带上TAG才干指定删除。

好今天到这里。

你可能感兴趣的文章
我的友情链接
查看>>
TOP 10 开源的推荐系统简介
查看>>
springcloud(第五篇)springcloud turbine
查看>>
springcloud(第五篇)springcloud turbine
查看>>
单臂路器实验不同vlan通信
查看>>
dedecms横向登录
查看>>
XmlToJson-xml对象转换为Json对象类
查看>>
pwd 命令
查看>>
MySQL备份(基于xtrabackup)的实战
查看>>
后腰椎间盘突出时期的生活
查看>>
MySQL Study之--Mysql数据库备份工具(mysqldump)
查看>>
android studio
查看>>
使用Graphviz下的dot工具绘制图像
查看>>
suid验证
查看>>
自制的游戏开发基本架构
查看>>
CentOS的yum源更改
查看>>
quartz 配置文档
查看>>
react-swipeable-views 使页面切换更加流畅
查看>>
spring事件学习和浅析
查看>>
JBPM学习(五):流程变量
查看>>