docker系列(二):镜像
1 引言
2 镜像管理
2.1 获取镜像
docker [image] pull 仓库名[:标签]
$ docker pull ubuntu
$ docker pull hub.c.163.com/public/ubuntu18.04
2.2 查看及查找镜像
$ docker images
$ docker [image] inspect 仓库名:标签
$ docker inspect ubuntu:18.04
$ docker history 仓库名:标签
2.3 删除镜像
$ docker rmi 仓库名:标签或镜像id
$ docker image rm 仓库名:标签或镜像id
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 18.04 7698f282e524 7 days ago 69.9MB
hello-world latest fce289e99eb9 4 months ago 1.84kB
$ docker tag hello-world:latest bye-world:8000
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 18.04 7698f282e524 7 days ago 69.9MB
bye-world 8000 fce289e99eb9 4 months ago 1.84kB
hello-world latest fce289e99eb9 4 months ago 1.84kB
$ docker rmi bye-world:8000
Untagged: bye-world:8000
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 18.04 7698f282e524 7 days ago 69.9MB
hello-world latest fce289e99eb9 4 months ago 1.84kB
$ docker rmi hello-world:latest
Error response from daemon: conflict: unable to remove repository reference "hello-world:latest" (must force) - container 53c855a9d4a9 is using its referenced image fce289e99eb9
$ docker rmi -f hello-world:latest
Untagged: hello-world:latest
Untagged: hello-world@sha256:6f744a2005b12a704d2608d8070a494ad1145636eeb74a570c56b94d94ccdbfc
Deleted: sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 18.04 7698f282e524 7 days ago 69.9MB
3 创建镜像
3.1 基于已有镜像容器创建镜像
$ docker commit [选项] 容器名或容器id [<仓库名>[:<标签名>]]
$ docker run -it ubuntu:18.04 /bin/bash
root@001b647aad4e:/#
root@001b647aad4e:/# git --version
bash: git: command not found
root@001b647aad4e:/# apt-get update
root@001b647aad4e:/# apt install git
root@001b647aad4e:/# git --version
git version 2.17.1
root@001b647aad4e:/# exit
exit
$ docker commit -m "Add git in ubuntu18.04" -a "God" 001b647aad4e ubuntu_git:1.0
sha256:30e6c7c480dc44743f0f030f4904089fb8568ad2333f8de3a22c4f6a71fdb451
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu_git 1.0 30e6c7c480dc About a minute ago 189MB
ubuntu 18.04 7698f282e524 8 days ago 69.9MB
3.2 使用dockerfile创建镜像
$ mkdir ubuntu_dockerfile_git
$ cd ubuntu_dockerfile_git/
$ touch dockerfile
FROM ubuntu:18.04 RUN apt-get update \
&& apt-get install -y git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
docker build [选项] <上下文路径/URL>
$ docker build -t ubuntu_dockerfile_git:1.0 .
$ docker images
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu_dockerfile_git 1.0 6e703a3b11e2 About a minute ago 163MB
ubuntu_git 1.0 30e6c7c480dc 20 hours ago 189MB
ubuntu 18.04 7698f282e524 9 days ago 69.9MB
$ docker run -it ubuntu_dockerfile_git:1.0 /bin/bash
root@18c03ae954ab:/# git --version
git version 2.17.1
4 总结
docker系列(二):镜像的更多相关文章
- Docker系列-(2) 镜像制作与发布
上篇文章引入了Docker的基本原理和操作,本节文章主要介绍如何制作Docker镜像和发布. 镜像文件结构 Docker镜像的本质是一系列文件的集合,这些文件依次叠加,形成了最后的镜像文件,类似于下图 ...
- Docker 系列二(操作镜像).
一.镜像管理 1.拉取镜像 docker pull [选项] [Docker Registry 地址[:端口号]/]仓库名[:标签] -- Docker 镜像仓库地址 :一般是 域名或者IP[:端口号 ...
- Docker系列二: docker常用命令总结
https://docs.docker.com/reference/ 官方命令总结地址 容器生命周期管理 1.docker run 创建一个新的容器并运行一个命令 docker run [optio ...
- Docker系列(二)组件介绍
镜像 镜像是一个只读的模版,可以用来创建Docker容器. 容器 Docker利用容器来运行应用,容器是从镜像创建的运行实例.它可以被启动.开始.停止.删除.每个容器都是互相隔离的,保证安全的平台.可 ...
- Docker系列二:Docker的基本结构
Docker的基本结构 Docker 的三大基础组件 Docker有三个重要的概念:仓库 , 镜像 和 容器 ,它们是Docker的三大基出组件 Docker的组织结构 Docker处于操作系统和虚拟 ...
- docker 系列 - 基础镜像环境和Docker常用命令整理
=======================docker 基础镜像环境 alpine=======================可以使用 docker search 命令搜索指定的 image, ...
- docker系列之镜像服务器
docker 的镜像服务器 docker-registry 是 docker 项目的组成部分. 前面在谈 docker 的命令时, 它的 pull/push 命令就是和镜像服务器打交道. 并且, do ...
- Docker系列之镜像瘦身(五)
前言 本节我们来讲讲在我们在构建镜像过程中不出问题,同时使得最后所构建的镜像文件大小尽可能最小,温馨提示:文中大图均可点击放大查看详细信息. 缓存(cache) Docker的优势之一在于提供了缓存, ...
- Docker系列(二):Docker基础命令
docker的部署安装(Linux kernel至少3.8以上): yum install docker docker1.8安装:(下面 是两个命令) # cat >/etc/yum.repos ...
- windows下部署.netcore+docker系列二 (unbuntu 18.4 下 安装 docker)亲测!!!
1.卸载sudo apt-get remove docker docker-engine docker.io containerd runc2.更新sudo apt-get update3.安装依赖包 ...
随机推荐
- linux 多线程编程-读写者问题
#include <cstdio> #include <pthread.h> #include <unistd.h> ]; int i,j; pthread_rwl ...
- Cloudera Manager 5 和 CDH5 本地(离线)安装指南
http://archive.cloudera.com/cm5/redhat/6/x86_64/cm/5.0.0/RPMS/x86_64/ http://archive-primary.clouder ...
- 京东ie6中轮播模块小图出现在大图上
请大家给个评论,给个支持!呵呵 本人最新一套模版小清新童装母婴日韩风全屏轮播(上线风暴),在审核时审核失败,报的是“ie6中全屏海报轮播是小图出现在大图中间的兼容性错误” 而本人本机出现的是小图基本上 ...
- C# 深化基本概念
关于IDisposable的Dispose方法 .Net中GC会自动回收托管资源, 对于非托管资源应该使用Dispose方法. 在使用Dispose方法时,应注意避免在Dispose内部中继续释放托管 ...
- mysql基础itcast笔记
1. 课程回顾 mysql基础 1)mysql存储结构: 数据库 -> 表 -> 数据 sql语句 2)管理数据库: 增加: create database 数据库 default c ...
- about future
最近又又又重复看了 star trek 星际迷航 back to the future 1/2/3 开始想象未来是什么样子的 1. 未来的开发语言 1.1[rust] or [golang] or [ ...
- JavaScript高级程序设计学习笔记第九章--客户端检测
1.能力检测:能力检测的目标不是识别特定的浏览器,而是识别浏览器的能力.(我的理解就是识别浏览器能做什么不能做什么) 2.怪癖检测:目标是识别浏览器的特殊行为.但与能力检测确认浏览器支持什么能力不同, ...
- Brute-Force-Attack on Triple-DES with Reduced Key Space
题目地址:https://www.mysterytwisterc3.org/en/challenges/level-ii/brute-force-attack-on-triple-des-with-r ...
- pig ERROR 2997: Encountered IOException. File or directory null does not exist.
grunt> ls 2014-03-30 19:58:31,344 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 2997: Enc ...
- Maven修改默认仓库为阿里云仓库
Maven 仓库默认在国外, 国内使用难免很慢,我们可以更换为阿里云的仓库. 第一步:修改 maven 根目录下的 conf 文件夹中的 setting.xml 文件,在 mirrors 节点上,添加 ...