基本使用命令:

[root@ipha-dev71- docker]# docker search python    # 搜索镜像
[root@ipha-dev71- docker]# docker pull centos/python--centos7 # 下载镜像
[root@ipha-dev71- docker]# docker images # 镜像查看(以下字段对应:仓库名称 版本号 镜像ID 创建时间 )
REPOSITORY TAG IMAGE ID CREATED SIZE
centos/python--centos7 latest 046b1b132fcb days ago 717MB
hello-world latest fce289e99eb9 months ago .84kB
training/webapp latest 6fae60ef3446 years ago 349MB
[root@ipha-dev71- docker]# docker rmi hello-world:latest # 删除镜像
[root@ipha-dev71- home]# docker save -o /home/docker_dir/python.tar centos/python--centos7 # 镜像保存,-o是指定写入的文件名和路径
[chenjl@ipha-dev71- docker_dir]$ ll
total
-rw------- root root Sep : python.tar
docker rmi -f 容器id      # 强制删除镜像
docker image prune # 批量删除未使用的容器

创建镜像:

1.从 Docker Hub 网站来搜索镜像,Docker Hub 网址为: https://hub.docker.com/  (就是上述介绍)

2.从已经创建的容器中更新镜像,并且提交这个镜像

3.使用 Dockerfile 指令来创建一个新的镜像

更新镜像:

[root@ipha-dev71- chenjl]# docker run -t -i ubuntu:14.04 /bin/bash  # -t指定版本 -i进入交互模式
root@f24c1984b49a:/# exit # 退出容器(退出交互模式)
[root@ipha-dev71- chenjl]# docker commit -m="has update" -a="mengmeng" f24c1984b49a mengmeng/ubuntu:v2 # -m是备注,-a是作者
sha256:0963e6b707d98b04a43d6b9641479dce221db063dbe3f22f8482869e7dec834d
[root@ipha-dev71- chenjl]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mengmeng/ubuntu v2 0963e6b707d9 seconds ago 188MB

更新镜像

构建镜像:

[root@ipha-dev71- test]# pwd
/home/docker_dir/test
[root@ipha-dev71- test]# ll
total
-rw-r--r-- root root Sep : Dockerfile
[root@ipha-dev71- test]# cat Dockerfile
FROM ubuntu:latest
CMD echo hello world!
[root@ipha-dev71- test]# docker build -t test-ubuntu:v1 . # 构建时指定版本
Sending build context to Docker daemon .048kB
Step / : FROM ubuntu:latest
latest: Pulling from library/ubuntu
5667fdb72017: Pull complete
d83811f270d5: Pull complete
ee671aafb583: Pull complete
7fc152dfb3a6: Pull complete
Digest: sha256:b88f8848e9a1a4e4558ba7cfc4acc5879e1d0e7ac06401409062ad2627e6fb58
Status: Downloaded newer image for ubuntu:latest
---> 2ca708c1c9cc
Step / : CMD echo hello world!
---> Running in 589a93408461
Removing intermediate container 589a93408461
---> 37c9cfa35a08
Successfully built 37c9cfa35a08
Successfully tagged test-ubuntu:v1
[root@ipha-dev71- test]# docker build -t test-ubuntu:v1 . # 可以看到第二次构建快速很多,由于是从缓存中读的数据
Sending build context to Docker daemon .048kB
Step / : FROM ubuntu:latest
---> 2ca708c1c9cc
Step / : CMD echo hello world!
---> Using cache
---> 37c9cfa35a08
Successfully built 37c9cfa35a08
Successfully tagged test-ubuntu:v1

接上:

[root@ipha-dev71- test]# docker images  # 查看构建的镜像
REPOSITORY TAG IMAGE ID CREATED SIZE
test-ubuntu v1 37c9cfa35a08 minutes ago .2MB
mengmeng/ubuntu v2 0963e6b707d9 minutes ago 188MB
12306_ticket latest ddc31ea56cd9 hours ago .84GB
<none> <none> d5857c982bb6 days ago 924MB
ubuntu latest 2ca708c1c9cc days ago .2MB
ubuntu 14.04 2c5e00d77a67 months ago 188MB
hello-world latest fce289e99eb9 months ago .84kB
training/webapp latest 6fae60ef3446 years ago 349MB
[root@ipha-dev71- test]# docker run 37c9cfa35a08 # 启动构建的镜像(只在第一次运行时使用,其余使用docker start)
hello world!

docker3-镜像的使用的更多相关文章

  1. Dockfile制作镜像

    讲一个简单的案例 @哈希码用来校验,这样子会安全 MAINTANIER可能将会被LABEL代替,仅仅说说明一下镜像信息罢了. 1.首先是我们创建一个镜像 [root@ELK-chaofeng08 ~] ...

  2. docker 镜像创建

    dockerfile FROM microsoft/aspnetcore:2.0 ARG source WORKDIR /app EXPOSE COPY ${source:-/} . ENTRYPOI ...

  3. 笔记-docker-3 使用

    笔记-docker-3 使用 1.      镜像 image是docker最重要的概念,docker运行容器前需要本地存在对应的镜像,如果没有,会尝试从默认镜像库下载. 1.1.    镜像获取 查 ...

  4. Docker---(3)Docker常用命令

    原文:Docker---(3)Docker常用命令 版权声明:欢迎转载,请标明出处,如有问题,欢迎指正!谢谢!微信:w1186355422 https://blog.csdn.net/weixin_3 ...

  5. NuGet镜像上线试运行

    为解决国内访问NuGet服务器速度不稳定的问题,我们用阿里云服务器搭建了一个NuGet镜像,目前已上线试运行. 使用NuGet镜像源的方法如下: 1)NuGet镜像源地址:https://nuget. ...

  6. SQL Server镜像自动生成脚本

    SQL Server镜像自动生成脚本 镜像的搭建非常繁琐,花了一点时间写了这个脚本,方便大家搭建镜像 执行完这个镜像脚本之后,最好在每台机器都绑定一下hosts文件,不然的话,镜像可能会不work 1 ...

  7. Android SDK 在线更新镜像服务器资源

    本文转自:http://blog.kuoruan.com/24.html.感谢原作者. 什么是Android SDK SDK:(software development kit)软件开发工具包.被软件 ...

  8. Jexus Web Server 完全傻瓜化图文配置教程(基于Ubuntu 12.04.3 64位)[内含Hyper-v 2012虚拟机镜像下载地址]

    1. 前言 近日有感许多新朋友想尝试使用Jexus,不过绝大多数都困惑徘徊在Linux如何安装啊,如何编译Mono啊,如何配置Jexus啊...等等基础问题,于是昨日向宇内流云兄提议,不如搞几个配置好 ...

  9. Windows Server 2012 磁盘管理之 简单卷、跨区卷、带区卷、镜像卷和RAID-5卷

    今天给客户配置故障转移群集,在Windows Server 2012 R2的系统上,通过iSCSI连接上DELL的SAN存储后,在磁盘管理里面发现可以新建 简单卷.跨区卷.带区卷.镜像卷.RAID-5 ...

  10. 如何用Dockerfile创建镜像

    本文原创,原文地址为:http://www.cnblogs.com/fengzheng/p/5181222.html 创建镜像的目的 首先说DockerHub或其它一些镜像仓库已经提供了够多的镜像,有 ...

随机推荐

  1. 53 (OC) 皮肤切换

    1:添加皮肤 1.1:iOS皮肤切换方案 http://www.cocoachina.com/ios/20171012/20762.html 1.2:整合 iOS几种换肤思路和demo https:/ ...

  2. Winform去掉标题栏后移动窗体

    第一步:声明全局变量->  private Point _HoverTreePosition; 第二步: #region 隐藏标题栏后移动窗口 private void Form_HoverTr ...

  3. 品Spring:实现bean定义时采用的“先进生产力”

    前景回顾 当我们把写好的业务代码交给Spring之后,Spring都会做些什么呢? 仔细想象一下,再稍微抽象一下,Spring所做的几乎全部都是: “bean的实例化,bean的依赖装配,bean的初 ...

  4. 阿里巴巴 Sentinel + InfluxDB + Chronograf 实现监控大屏

    前言 在上一篇推文中,我们使用时序数据库 InfluxDb 做了流控数据存储,但是数据存储不是目的,分析监控预警才是最终目标,那么问题来了,如何更好的实现呢?用过阿里巴巴 Sentinel 控制台的小 ...

  5. SpringBoot起飞系列-入门(一)

    一.SpringBoot简介 1.1 什么是SpringBoot 说到spring系列,可能大家都很熟悉,spring.springmvc,美之名曰:spring全家桶,那么springboot其实也 ...

  6. Mybatis逆向工程过程中出现targetRuntime in context mybatisGenerator is invalid

    最开始设置的Mybatis,但是逆向工程准备就绪后出现问题 报错为targetRuntime in context mybatisGenerator is invalid 后来修改为Mybatis3能 ...

  7. [python]汉诺塔问题

    相传在古印度圣庙中,有一种被称为汉诺塔(Hanoi)的游戏.该游戏是在一块铜板装置上,有三根杆(编号A.B.C),在A杆自下而上.由大到小按顺序放置64个金盘(如下图).游戏的目标:把A杆上的金盘全部 ...

  8. ELK搭建实时日志分析平台

    ELK搭建实时日志分析平台 导言 ELK由ElasticSearch.Logstash和Kiabana三个开源工具组成,ELK平台可以同时实现日志收集.日志搜索和日志分析的功能.对于生产环境中海量日志 ...

  9. Vue2.0+ElementUI实现表格翻页的实例

    参考地址: https://www.cnblogs.com/zhouyifeng/p/7706815.html

  10. Mysql高手系列 - 第19篇:mysql游标详解,此技能可用于救火

    Mysql系列的目标是:通过这个系列从入门到全面掌握一个高级开发所需要的全部技能. 这是Mysql系列第19篇. 环境:mysql5.7.25,cmd命令中进行演示. 代码中被[]包含的表示可选,|符 ...