简介

Docker镜像是什么?

它是一个只读的文件,就类似于我们安装操作系统时候所需要的那个iso光盘镜像,通过运行这个镜像来完成各种应用的部署。

这里的镜像就是一个能被docker运行起来的一个程序。

查看镜像资源操作命令

docker image
Usage:	docker image COMMAND

Manage images

Options:
--help Print usage Commands:
build Build an image from a Dockerfile
history Show the history of an image
import Import the contents from a tarball to create a filesystem image
inspect Display detailed information on one or more images
load Load an image from a tar archive or STDIN
ls List images
prune Remove unused images
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rm Remove one or more images
save Save one or more images to a tar archive (streamed to STDOUT by default)
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE Run 'docker image COMMAND --help' for more information on a command.

搜索镜像资源

命令格式:docker search [image_name]
[root@VM_0_4_centos docker]# docker search nginx
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/nginx Official build of Nginx. 12386 [OK]
docker.io docker.io/jwilder/nginx-proxy Automated Nginx reverse proxy for docker c... 1704 [OK]
docker.io docker.io/richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable ... 749 [OK]
docker.io docker.io/linuxserver/nginx An Nginx container, brought to you by Linu... 84
docker.io docker.io/bitnami/nginx Bitnami nginx Docker Image 73 [OK]
docker.io docker.io/tiangolo/nginx-rtmp Docker image with Nginx using the nginx-rt... 60 [

OFFICIAL [OK] 说明是官方提供的镜像

获取镜像

命令格式:docker pull [image_name]

拉取mysql镜像

[root@VM_0_4_centos docker]# docker pull docker.io/mysql
Using default tag: latest
Trying to pull repository docker.io/library/mysql ...
latest: Pulling from docker.io/library/mysql
d599a449871e: Pull complete
f287049d3170: Pull complete
08947732a1b0: Pull complete
96f3056887f2: Pull complete
871f7f65f017: Pull complete
1dd50c4b99cb: Pull complete
5bcbdf508448: Pull complete
a59dcbc3daa2: Pull complete
13e6809ab808: Pull complete
2148d51b084d: Pull complete
93982f7293d7: Pull complete
e736330a6d9c: Pull complete
Digest: sha256:c93ba1bafd65888947f5cd8bd45deb7b996885ec2a16c574c530c389335e9169
Status: Downloaded newer image for docker.io/mysql:latest

查看本地镜像

命令格式:docker image ls
命令格式:docker image

删除镜像资源

命令格式:docker image rm [image_id/image_name:image_version]
命令格式:docker rmi [image_id/image_name:image_version]

镜像重命名

docker tag [old_image]:[old_version] [new_image]:[new_version]
[root@VM_0_4_centos docker]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/mysql latest d435eee2caa5 4 weeks ago 456 MB
[root@VM_0_4_centos docker]# docker tag docker.io/mysql:latest my_mysql:1.0
[root@VM_0_4_centos docker]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/mysql latest d435eee2caa5 4 weeks ago 456 MB
my_mysql 1.0 d435eee2caa5 4 weeks ago 456 MB

导出镜像

将已经下载好的镜像,导出到本地,以备后用

命令格式:docker save -o [包文件] [镜像]
命令格式:docker save [镜像1] ... [镜像n] > [包文件]
docker save  docker.io/mysql > mysql.tar

导入镜像

命令格式:docker load < [image.tar_name]
命令格式:docker load --input [image.tar_name]
docker load < mysql.tar

Docker(二) 镜像的更多相关文章

  1. 生产环境项目问题记录系列(二):Docker打包镜像Nuget包因权限问题还原失败

    docker打包镜像遇到一个因为nuget权限验证问题导致镜像打包失败的问题,公司Nuget包用的是tfs管理的,tfs有权限验证,结果导致nuget还原失败,原有的NuGet.config文件如下: ...

  2. Docker:镜像操作和容器操作

    镜像操作 列出镜像: $ sudo docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE hello-world latest 0a6b ...

  3. 使用Nexus3构建Docker私有镜像仓库

    一.安装Nexus3 Nexus3是Sonatype提供的仓库管理平台,Nuexus Repository OSS3能够支持Maven.npm.Docker.YUM.Helm等格式数据的存储和发布:并 ...

  4. Docker常用镜像

    Docker,具有快捷方便的特性,机器上不需要安装软件和进行各种配置,拉取镜像,一行命令即可启动服务,不使用时,一行命令关闭容器即可,快捷方便,干净.利索.建议将本地的redis.mysql.kafk ...

  5. docker(三) 镜像和容器常用命令

    一.镜像操作 1.搜索镜像 可以直接在Docker Hub 直接搜索镜像,当然也可以使用命令来搜索. docker search 名称 docker search tomcat 2.拉取镜像 dock ...

  6. docker 拷贝镜像文件

    1.概述 我们制作好镜像后,有时需要将镜像复制到另一台服务器使用. 能达到以上目的有两种方式,一种是上传镜像到仓库中(本地或公共仓库),但是另一台服务器很肯能只是与当前服务器局域网想通而没有公网的,所 ...

  7. Docker搭建镜像仓库和配置缓冲地点

    Docker搭建镜像仓库和配置缓冲地点 参考网址:https://docs.docker.com/engine/reference/commandline/dockerd/#options 一.配置D ...

  8. Docker dockerfile镜像编码

    一. 大多数docker基础镜像使用locale查看编码,发现默认编码都是POSIX,这会导致中文乱码.解决方法如下: 二.首先使用locale -a查看容器所有语言环境 三.dockerfile中加 ...

  9. docker之镜像管理命令

    一.docker image 镜像管理命令 指令 描述ls 列出本机镜像build 构建镜像来自Dockerfilehistory 查看镜像历史inspect 显示一个或多个镜像详细信息pull 从镜 ...

随机推荐

  1. 一些实战中总结的 javascript 开发经验

    Javascript 的很多扩展的特性是的它变得更加的犀利, 同时也给予程序员机会创建更漂亮并且更让用户喜欢的网站. 尽管很多的开发人员都乐于颂扬 javascript,但是仍旧有人看到它的阴暗面. ...

  2. 更新到@vue/cli 4.1.1版本的前端开发前的准备

    一.概念简述 1.node.js目的是提供一个JS的运行环境. 2.npm(node package manager)是一个JS包管理器. 二.检查自己的电脑是否已安装相关配置 1.查看node.js ...

  3. UVW平台运动控制算法以及matlab仿真

    UVW平台运动控制算法以及matlab仿真   最近公司同事因为对某视觉对位平台的运动控制算法有疑问,所以来请教我.由于我也是第一次接触到UVW自动对位平台(也可以叫XXY自动对位平台),于是找了一些 ...

  4. jquery中如何判断checkbox是否选中

    jquery代码: <script> $(document).ready(function() { $('#checkbox-id').click(function() { if($('# ...

  5. SpringJDBC的使用(转载)

    转载自   https://www.yiibai.com/spring/maven-spring-jdbc-example.html 工具: eclipse4.7.2及mysql-8.0.13 项目最 ...

  6. 【题解】P4503 [CTSC2014]企鹅QQ(哈希)

    [题解]P4503 [CTSC2014]企鹅QQ(哈希) 考虑这样一种做法,将每个字符串的删去某个字符的新字符串的哈希值存下来,然后最后\(sort\)一遍双指针统计每个值相同的数的个数\(x\),这 ...

  7. $loj$10222 佳佳的$Fibonacci$ 矩阵快速幂

    正解:矩阵快速幂 解题报告: 我永远喜欢loj! 一看到这个就应该能想到矩阵快速幂? 然后就考虑转移式,发现好像直接想不好想,,,主要的问题在于这个*$i$,就很不好搞$QAQ$ 其实不难想到,$\s ...

  8. SimpleFactoryPattern(简单工厂模式)-----Java/.Net

    工厂模式是最常用的一种创建型模式,通常所说的工厂模式一般是指工厂方法模式.本篇是是工厂方法模式的“小弟”,我们可以将其理解为工厂方法模式的预备知识,它不属于GoF 23种设计模式,但在软件开发中却也应 ...

  9. linux MySQL 5.7+keepalived 主备服务器自主切换

    一.环境准备1.关闭防火墙与selinux systemctl stop firewalld setenforce 0 sed -i 's/SELINUX=.*/SELINUX=disabled/g' ...

  10. 一定要你明白Java中的volatile

    今天Tony来和大家聊聊Java中关键字volatile. 字节码 首先volatile int a = 3;和int a = 3;, 加不加volatile关键字,最终生成的字节码都一样的.有兴趣的 ...