Docker:镜像介绍与镜像仓库
Brief
:Docker镜像介绍
什么是Docker镜像
和操作系统安装镜像类似,Docker镜像是一个容器的基础,它由文件系统叠加而成。最底端是一个引导文件系统,类似Linux/Unix的引导文件系统,镜像也是Docker生命周期中的“构建”部分。镜像是基于联合(Union)文件系统的一种层式的结构,由一系列指令一步一步构建出来。可以把镜像当作容器的“源代码”。镜像体积很小,非常“便携”,易于分享、存储和更新。
获取Docker镜像仓库
镜像仓库是用来存放各种镜像的存储中心。Docker提供默认官方的仓库 https://hub.docker.com。 镜像仓库存储的镜像分为公开或者私用,公开的任何人都可以拉取执行,私有的仅有限访问。也可以通过docker命令直接搜索拉取镜像。
docker 镜像搜索
通过网页搜索
docker命令搜索
[root@tvl-cnss-uat-3127 pro]# docker search ubuntu NAME DESCRIPTION STARS OFFICIAL AUTOMATED ubuntu Ubuntu is a Debian-based Linux operating sys… 11897 [OK] dorowu/ubuntu-desktop-lxde-vnc Docker image to provide HTML5 VNC interface … 500 [OK] websphere-liberty WebSphere Liberty multi-architecture images … 268 [OK] rastasheep/ubuntu-sshd Dockerized SSH service, built on top of offi… 250 [OK] consol/ubuntu-xfce-vnc Ubuntu container with "headless" VNC session… 233 [OK] ubuntu-upstart Upstart is an event-based replacement for th… 110 [OK] neurodebian NeuroDebian provides neuroscience research s… 80 [OK] 1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 50 [OK] ubuntu-debootstrap debootstrap --variant=minbase --components=m… 44 [OK] open-liberty Open Liberty multi-architecture images based… 42 [OK] nuagebec/ubuntu Simple always updated Ubuntu docker images w… 24 [OK] i386/ubuntu Ubuntu is a Debian-based Linux operating sys… 24 1and1internet/ubuntu-16-apache-php-5.6 ubuntu-16-apache-php-5.6 14 [OK] 1and1internet/ubuntu-16-apache-php-7.0 ubuntu-16-apache-php-7.0 13 [OK] 1and1internet/ubuntu-16-nginx-php-phpmyadmin-mariadb-10 ubuntu-16-nginx-php-phpmyadmin-mariadb-10 11 [OK] 1and1internet/ubuntu-16-nginx-php-5.6-wordpress-4 ubuntu-16-nginx-php-5.6-wordpress-4 8 [OK] 1and1internet/ubuntu-16-nginx-php-5.6 ubuntu-16-nginx-php-5.6 8 [OK] 1and1internet/ubuntu-16-apache-php-7.1 ubuntu-16-apache-php-7.1 6 [OK] 1and1internet/ubuntu-16-nginx-php-7.0 ubuntu-16-nginx-php-7.0 4 [OK] pivotaldata/ubuntu A quick freshening-up of the base Ubuntu doc… 4 pivotaldata/ubuntu16.04-build Ubuntu 16.04 image for GPDB compilation 2 pivotaldata/ubuntu-gpdb-dev Ubuntu images for GPDB development 1 1and1internet/ubuntu-16-php-7.1 ubuntu-16-php-7.1 1 [OK] smartentry/ubuntu ubuntu with smartentry 1 [OK] 1and1internet/ubuntu-16-sshd ubuntu-16-sshd 1 [OK] [root@tvl-cnss-uat-3127 pro]#
NAME:镜像名
DESCRIPTION:镜像描述
STARS:被用户收藏次数
OFFCIAL:是否是官方镜像 官方镜像是由Docker官方或者受Docker邀请或者合作发布的镜像,这些镜像是安全性能卓越且持续维护的产品,值得信赖
AUTOMATED:指的这些镜像是系统自动构建的
Docker镜像拉取到本地系统
通过docker pull 命令获取镜像
[root@tvl-cnss-uat-3127 pro]# docker pull nginx Using default tag: latest latest: Pulling from library/nginx 45b42c59be33: Already exists 8acc495f1d91: Pull complete ec3bd7de90d7: Pull complete 19e2441aeeab: Pull complete f5a38c5f8d4e: Pull complete 83500d851118: Pull complete Digest: sha256:f3693fe50d5b1df1ecd315d54813a77afd56b0245a404055a946574deb6b34fc Status: Downloaded newer image for nginx:latest docker.io/library/nginx:latest [root@tvl-cnss-uat-3127 pro]#
镜像的指定由 {镜像名}:{标签名} 共同指定,未使用标签名时默认指定为latest。nginx等于nginx:latest,标签类似版本号的概念
查看本地已经拉取的镜像
[root@tvl-cnss-uat-3127 pro]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 35c43ace9216 2 weeks ago 133MB redis latest eb0ab2d55fdf 3 weeks ago 104MB ubuntu latest f63181f19b2f 6 weeks ago 72.9MB registry latest 678dfa38fcfa 2 months ago 26.2MB centos latest 300e315adb2f 2 months ago 209MB [root@tvl-cnss-uat-3127 pro]#
可以通过docker rmi命令删除本地已经存在且不需要的镜像
docker rmi nginx:latest # 等同于 docker rmi 35c43ace9216 指定镜像id或者名称都可以