镜像特点
1. 分层存储的文件
2.一个软件运行环境
3.一个镜像可以创建多个容器
4.一种标准交付
5.不包含Linux内核而又精简的Linux操作系统
6.不是一个单一的文件而是由多层构成的,可以通过docker history 镜像名字查看镜像里各层级内容及大小,每层都对应一个dockerfile中一个指令,镜像默认存储的路径/var/lib/docker/
[root@mast ~]# docker history nginx:latest IMAGE CREATED CREATED BY SIZE COMMENT f09fe80eb0e7 11 days ago /bin/sh -c #(nop) CMD ["nginx" "-g" "daemon… 0B <missing> 11 days ago /bin/sh -c #(nop) STOPSIGNAL SIGTERM 0B <missing> 11 days ago /bin/sh -c #(nop) EXPOSE 80 0B <missing> 11 days ago /bin/sh -c ln -sf /dev/stdout /var/log/nginx… 22B <missing> 11 days ago /bin/sh -c set -x && apt-get update && apt… 53.9MB <missing> 11 days ago /bin/sh -c #(nop) ENV NJS_VERSION=1.15.8.0.… 0B <missing> 11 days ago /bin/sh -c #(nop) ENV NGINX_VERSION=1.15.8-… 0B <missing> 11 days ago /bin/sh -c #(nop) LABEL maintainer=NGINX Do… 0B <missing> 11 days ago /bin/sh -c #(nop) CMD ["bash"] 0B <missing> 11 days ago /bin/sh -c #(nop) ADD file:5a6d066ba71fb0a47… 55.3MB
镜像搜索
[root@mast ~]# docker search tomcat NAME DESCRIPTION STARS OFFICIAL AUTOMATED tomcat Apache Tomcat is an open source implementati… 2283 [OK] tomee Apache TomEE is an all-Apache Java EE certif… 61 [OK] dordoka/tomcat Ubuntu 14.04, Oracle JDK 8 and Tomcat 8 base… 52 [OK] davidcaste/alpine-tomcat Apache Tomcat 7/8 using Oracle Java 7/8 with… 34 [OK] bitnami/tomcat Bitnami Tomcat Docker Image 27 [OK] cloudesire/tomcat Tomcat server, 6/7/8 14 [OK] aallam/tomcat-mysql Debian, Oracle JDK, Tomcat & MySQL 11 [OK] tutum/tomcat Base docker image to run a Tomcat applicatio… 11 meirwa/spring-boot-tomcat-mysql-app a sample spring-boot app using tomcat and My… 11 [OK] jeanblanchard/tomcat Minimal Docker image with Apache Tomcat 8 arm32v7/tomcat Apache Tomcat is an open source implementati… 6 maluuba/tomcat7-java8 Tomcat7 with java8. 3 rightctrl/tomcat CentOS , Oracle Java, tomcat application ssl… 3 [OK] fabric8/tomcat-8 Fabric8 Tomcat 8 Image 2 [OK] arm64v8/tomcat Apache Tomcat is an open source implementati… 2 amd64/tomcat Apache Tomcat is an open source implementati… 2 99taxis/tomcat7 Tomcat7 1 [OK] camptocamp/tomcat-logback Docker image for tomcat with logback integra… 1 [OK] 1and1internet/debian-9-java-8-tomcat-8.5 Our tomcat 8.5 image 0 [OK] s390x/tomcat Apache Tomcat is an open source implementati… 0 picoded/tomcat7 tomcat7 with jre8 and MANAGER_USER / MANAGER… 0 [OK] oobsri/tomcat8 Testing CI Jobs with different names. 0 cfje/tomcat-resource Tomcat Concourse Resource 0 jelastic/tomcat An image of the Tomcat Java application serv… 0 swisstopo/service-print-tomcat backend tomcat for service-print "the true, … 0
镜像加速器配置
参考 https://www.daocloud.io/mirror
Linux curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io 该脚本可以将 --registry-mirror 加入到你的 Docker 配置文件 /etc/docker/daemon.json 中。适用于 Ubuntu14.04、Debian、CentOS6 、CentOS7、Fedora、Arch Linux、openSUSE Leap 42.1,其他版本可能有细微不同。更多详情请访问文档。 macOS Docker For Mac 右键点击桌面顶栏的 docker 图标,选择 Preferences ,在 Daemon 标签(Docker 17.03 之前版本为 Advanced 标签)下的 Registry mirrors 列表中加入下面的镜像地址: http://f1361db2.m.daocloud.io 点击 Apply & Restart 按钮使设置生效。 Docker Toolbox 等配置方法请参考帮助文档。 Windows Docker For Windows 在桌面右下角状态栏中右键 docker 图标,修改在 Docker Daemon 标签页中的 json ,把下面的地址: http://f1361db2.m.daocloud.io 加到" registry-mirrors"的数组里。点击 Apply 。
镜像操作命令
[root@mast ~]# docker pull redis 容器下载 Using default tag: latest latest: Pulling from library/redis 6ae821421a7d: Already exists e3717477b42d: Pull complete 8e70bf6cc2e6: Pull complete 0f84ab76ce60: Pull complete 0903bdecada2: Pull complete 492876061fbd: Pull complete Digest: sha256:dd5b84ce536dffdcab79024f4df5485d010affa09e6c399b215e199a0dca38c4 Status: Downloaded newer image for redis:latest [root@mast ~]# docker search mysql 镜像搜索 NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 7824 [OK] mariadb MariaDB is a community-developed fork of MyS… 2584 [OK] mysql/mysql-server Optimized MySQL Server Docker images. Create… 590 [OK] zabbix/zabbix-server-mysql Zabbix Server with MySQL database support 167 [OK] hypriot/rpi-mysql RPi-compatible Docker Image with Mysql 106 zabbix/zabbix-web-nginx-mysql Zabbix frontend based on Nginx web-server wi… 91 [OK] centurylink/mysql Image containing mysql. Optimized to be link… 60 [OK] 1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 49 [OK] centos/mysql-57-centos7 MySQL 5.7 SQL database server 47 mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr… 41 tutum/mysql Base docker image to run a MySQL database se… 31 bitnami/mysql Bitnami MySQL Docker Image 25 [OK] schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic backup… 24 [OK] zabbix/zabbix-proxy-mysql Zabbix proxy with MySQL database support 20 [OK] linuxserver/mysql A Mysql container, brought to you by LinuxSe… 20 centos/mysql-56-centos7 MySQL 5.6 SQL database server 12 circleci/mysql MySQL is a widely used, open-source relation… 10 mysql/mysql-router MySQL Router provides transparent routing be… 8 openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 image… 6 dsteinkopf/backup-all-mysql backup all DBs in a mysql server 5 [OK] openzipkin/zipkin-mysql Mirror of https://quay.io/repository/openzip… 2 jelastic/mysql An image of the MySQL database server mainta… 1 ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL 0 [OK] cloudposse/mysql Improved `mysql` service with support for `m… 0 [OK] cloudfoundry/cf-mysql-ci Image used in CI of cf-mysql-release 0 查看系统容器镜像 [root@mast ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis latest 0f55cf3661e9 12 days ago 95MB nginx latest f09fe80eb0e7 12 days ago 109MB centos latest 1e1148e4cc2c 2 months ago 202MB 删除镜像 [root@mast ~]# docker rmi nginx Untagged: nginx:latest Untagged: nginx@sha256:dd2d0ac3fff2f007d99e033b64854be0941e19a2ad51f174d9240dda20d9f534 Deleted: sha256:f09fe80eb0e75e97b04b9dfb065ac3fda37a8fac0161f42fca1e6fe4d0977c80 Deleted: sha256:355e42205f69706706acf084bc2ed484ea5c034a8861b5bcebb7d8bf141fd686 Deleted: sha256:70cc0be2e302cca187cfadaaf528005d004bec56d46ae890a8a06bdd96768ef1 查看运行的容器 [root@mast ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 805df72012c8 nginx "/bin/sh" 24 hours ago Up 24 hours 80/tcp cranky_kapitsa 查看所有容器 [root@mast ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 805df72012c8 nginx "/bin/sh" 24 hours ago Up 24 hours 80/tcp cranky_kapitsa ef5bddd4dd05 centos "/bin/bash" 25 hours ago Exited (0) 24 hours ago 删除停止的容器 [root@mast ~]# docker rm ef5bddd4dd05 ef5bddd4dd05 [root@mast ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 805df72012c8 nginx "/bin/sh" 24 hours ago Up 24 hours 80/tcp cranky_kapitsa 删除正在运行的容器 [root@mast ~]# docker rm -f 805df72012c8 805df72012c8 [root@mast ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
镜像导出为文件操作
[root@mast ~]# docker image save nginx > web.tar [root@mast ~]# du -sh web.tar 108M web.tar [root@mast ~]# docker image load < web.tar Loaded image: nginx:latest