Docker 镜像命令

news/2024/7/4 13:04:50

为什么80%的码农都做不了架构师?>>>   hot3.png

前言

镜像(image)是 docker 中的三大核心要素之一,是我们必须要掌握的内容.

先来瞄一眼跟镜像相关的命令帮助:

docker image --help
# 通常会输出

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 镜像命令实践

搜索镜像

类比:我们想玩一个游戏,我们需要先去搜索下

# 搜索远程仓库中的 nginx 镜像
docker search nginx
# 通常会输出
NAME                          DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
nginx                         Official build of Nginx.                        6217      [OK]
jwilder/nginx-proxy           Automated Nginx reverse proxy for docker c...   1051                 [OK]
richarvey/nginx-php-fpm       Container running Nginx + PHP-FPM capable ...   388                  [OK]
webdevops/php-nginx           Nginx with PHP-FPM                              80                   [OK]
million12/nginx-php           Nginx + PHP-FPM 5.5, 5.6, 7.0 (NG), CentOS...   77                   [OK]
h3nrik/nginx-ldap             NGINX web server with LDAP/AD, SSL and pro...   38                   [OK]
bitnami/nginx                 Bitnami nginx Docker Image                      30                   [OK]
evild/alpine-nginx            Minimalistic Docker image with Nginx            16                   [OK]
funkygibbon/nginx-pagespeed   nginx + ngx_pagespeed + openssl on docker-...   11                   [OK]
webdevops/nginx               Nginx container                                 7                    [OK]
webdevops/php-nginx-dev       PHP with Nginx for Development (eg. with x...   6                    [OK]
# ...
# Tips:这里需要关注的是*OFFICIAL*,代表该镜像是官方的.

拉取镜像

类比:我们搜索到想要的游戏,然后需要把游戏的安装包下载过来

# 拉取名为 nginx 的镜像到本地
docker pull nginx
# 通常会输出

查看镜像

类比:游戏的安装包下载完成/要安装游戏时,我们可以看下本机已经有哪些游戏的安装包.

# 拉取完成/要使用镜像时,我们可以看下本机已经有哪些镜像
docker image list
# 通常会输出
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              958a7ae9e569        2 weeks ago         109MB
# ...
# Tips:这里的镜像名称和镜像ID是我们通常要关注的,因为经常会需要使用它们.

如果需要查看镜像的更多信息,可以试试docker inspect命令:

docker inspect imageId/imageName
# 通常会输出

删除镜像

类比:我们不需要某个游戏安装包了,我们可以把它删除,以节省磁盘空间,看的也清爽点

# 移除一个镜像
docker image remove imageId/imageName 

# 移除多个镜像
# 这里删除2个镜像
docker image remove image1Id/image1Name image2Id/image2Name

待续...

转载于:https://my.oschina.net/taadis/blog/974130


http://www.niftyadmin.cn/n/2610700.html

相关文章

asp.net小数点四舍五入的正确写法

一、Math.Round默认规则 四舍六入五取偶(又称四舍六入五留双),即: 当舍去位的数值小于5时,直接舍去该位;当舍去位的数值大于等于6时,在舍去该位的同时向前位进一&#…

python链表的创建_python单链表中如何插入和输出节点?(代码示例)

python单链表中如何插入和输出节点?下面本篇文章就来带大家了解一下单链表是什么,如何对单链表执行的一些非常基本的操作,例如:插入、输出,希望对大家有所帮助。单链表是什么? 首先在了解单链表之前&#x…

python语言的作者是_Python语言

第1章 Python 3概述 1.1 Python简介 2 1.1.1 Python的前世今生 2 1.1.2 Python的应用场合 2 1.1.3 Python的特性 3 1.1.4 选择Python的版本 4 1.1.5 如何学习Python 5 1.2 Python环境构建 5 1.2.1 在Windows系统中安装Python 3 5 1.2.2 在Linux系统中安装Python 3 8 1.2.3 在Ma…

MVC中BeginForm的使用

一、常用形式 Html.BeginForm(actionName,controllerName,method,htmlAttributes){} 二、参数说明 actionName:操作方法的名称,System.String。 controllerName:控制器的名称,System.String。 method&…

如何利用python整合excel_如何使用Python处理Excel

编程应该作为必修加入小学生课程表,这是思维方式的锻炼。 ——沃兹基朔德(借梗) 离开代码也有快两年了。期间其实一直有重新拾起的想法,只是没有模板刺激的动力,加上又懒… 刚好这段时间项目进入一个阶段,一方面需要对上个阶段的产…

Android的 ViewPager 学习笔记

说明&#xff1a; ViewPager用于实现多页面的切换效果&#xff0c;该类存在于Google的兼容包里面&#xff0c;所以在引用时记得在BuilldPath中加入“android-support-v4.jar” 主布局文件 main.xml <?xml version"1.0" encoding"utf-8"?> <Line…

mvc中Scripts.Render的用法

&#xfeff;&#xfeff;一、配置BundleConfig.cs文件 1、首先要在App_Start 里面BundleConfig.cs 文件里面 添加要包含的css文件 2、BundleConfig就是一个微软新加的 一个打包的配置类 3、BundleConfig用来Add 各种Bundle 4、BundleConfig配置信息如下&#xff1a; public…

《读完忍不住流泪的文章:母亲,我怎么让妳等了那么久...》

母亲&#xff0c;我怎么让妳等了那么久...文/ 刘继荣 2009/06/03 10:08 母亲真的老了&#xff0c;变得孩子般缠人&#xff0c;每次打电话来&#xff0c;总是满怀热诚地问&#xff1a;「你什么时候回家&#xff1f;」 且不说相隔一千多里路&#xff0c;要转三次车。光是工作、…