基本使用命令:

[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. TestNG(六) 忽略测试

    package com.course.testng.suite; import org.testng.annotations.Test; public class IgnoreTest { @Test ...

  2. Python3.7.4入门-0/1To Begin/数据类型与结构

    0 To Begin //:向下取整除法 **:乘方 在交互模式下,上一次打印出来的表达式被赋值给变量 _ 如果不希望前置了 \ 的字符转义成特殊字符,可以使用 原始字符串 方式,在引号前添加 r 即 ...

  3. nginx如何配置负载均衡

    自己学习用 面试回答如下: 在nginx里面配置一个upstream,然后把相关的服务器ip都配置进去.然后采用轮询的方案,然后在nginx里面的配置项里,proxy-pass指向这个upstream ...

  4. 【linux】【docker】docker私服安装

    前言 系统环境:Centos7.jdk1.8 docker私服:可以把项目通过dockerfile文件build成docker镜像,供其他环境拉取.部署在本地,私有化. 安装 dockerHUB私服 ...

  5. 使用System.Text.Json处理Json文档以及部分坑

    System.Text.Json处理Json文档需要用到JsonDocument,JsonElement,JsonProperty. JsonDocument就是一个表示Json文档的东西,JsonE ...

  6. Mybaits-从零开始-Hello World(暂不考虑命名规范化)

    1.mybatis-config.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE ...

  7. Linux下查看版本信息

    Linux下如何查看版本信息, 包括位数.版本信息以及CPU内核信息.CPU具体型号等.   1.# uname -a   (Linux查看版本当前操作系统内核信息)   2.# cat /proc/ ...

  8. Python邮件发送功能

    import smtplibfrom email.mime.text import MIMEText_user = "1147016115@qq.com"#发件人_pwd = &q ...

  9. 纯 CSS 实现幻灯片播放

    介绍:   今日看到一道面试题,关于 使用纯CSS,不利用js, 写一个简单的幻灯效果页面.于是做了一个小demo,建议使用chrome,IE11查看~~ 主要思想: 利用 CSS3的 伪类选择器 : ...

  10. 编程小技巧之 Linux 文本处理命令

    合格的程序员都善于使用工具,正所谓君子性非异也,善假于物也.合理的利用 Linux 的命令行工具,可以提高我们的工作效率. 本文简单的介绍三个能使用 Linux 文本处理命令的场景,给大家开阔一下思路 ...