30选5玩法|福彩30选5开奖结果321|
 

标签:docker

一看必会系列:docker 实战14 docker国内镜像加速推荐

No Comments Docker

 

用了很多源,这个飞一样的速度,注意要注册帐号。

 

https://www.daocloud.io/mirror#accelerator-doc

 

配置 Docker 加速器
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 ?#23567;?#36866;用于 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 。

Docker Toolbox 等配置方法请参考帮助文档。

拉取被国外的k8s docker image

No Comments Docker

-----------拉取被屏蔽的docker image

将 k8s.gcr.io 替换成registry.cn-hangzhou.aliyuncs.com/google_containers/ 即可

[[email protected] heapster]# grep gcr.io *

grafana.yaml: image: k8s.gcr.io/heapster-grafana-amd64:v5.0.4

heapster.yaml: image: k8s.gcr.io/heapster-amd64:v1.5.4

influxdb.yaml: image: k8s.gcr.io/heapster-influxdb-amd64:v1.5.2

[[email protected] heapster]# docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-grafana-amd64:v5.0.4

拉取被国外的k8s docker image

No Comments Docker

-----------拉取被屏蔽的docker image

将 k8s.gcr.io 替换成hangzhou.aliyuncs.com/google_containers/ 即可

[[email protected] heapster]# grep gcr.io *

grafana.yaml: image: k8s.gcr.io/heapster-grafana-amd64:v5.0.4

heapster.yaml: image: k8s.gcr.io/heapster-amd64:v1.5.4

influxdb.yaml: image: k8s.gcr.io/heapster-influxdb-amd64:v1.5.2

[[email protected] heapster]# docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/heapster-grafana-amd64:v5.0.4

一看必会系列:docker tomcat容器测试

No Comments 容器技术

仓库服务器操作

拉的国内源,原厂源太慢
docker search registry.docker-cn.com/library/tomcat
docker pull registry.docker-cn.com/library/tomcat
docker images

打包推到本地

docker tag registry.docker-cn.com/library/tomcat 192.168.142.130:5000/tomcat:v1
docker images
docker images |grep 5000
docker ps
docker push 192.168.142.130:5000/tomcat:v1
docker images

应用服务器操作

docker pull 192.168.142.130:5000/tomcat:v1
vim /opt/dockerfiles/Dockerfile
FROM 192.168.142.130:5000/tomcat:v1
copy login.jsp /usr/local/tomcat/webapps/

docker build -t jefftomcat:v2 .

docker run -itd -p 808:8080  jefftomcat:v2 /bin/bash

更新源
建议先更新国内源  方式http://www.rygqfb.tw/?p=3821
apt-get update && apt-get install vim -y

apt-get install vim
cat /proc/version
uname
uname -a
cat /proc/version
sb_reease -a
rb_release
cat /etc/issue  发现版本是debian
apt-get install net-tools
netstat -ntlp    发现端口没起动

cd bin/
./startup.sh    国内源和原厂不一样,不是自己启动,需要手动运行
netstat -ntlp
java -version
[email protected]:/usr/local/tomcat/webapps# !net
netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      438/java           
tcp6       0      0 :::8009                 :::*                    LISTEN      438/java           
tcp6       0      0 :::8080                 :::*                    LISTEN      438/java

测试文件放这里
[email protected]:/usr/local/tomcat/webapps/ROOT/login.jsp

login.jsp内容如下
<%@ page import="java.sql.*" language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>登录界面</title>
</head>
<body>
    <center>
        <h1 style="color:red">登录</h1>
            <form id="indexform" name="indexForm" action="logincheck.jsp" method="post">
                <table border="0">
                    <tr>
                        <td>账号:</td>
                        <td><input type="text" name="username"></td>
                    </tr>
                    <tr>
                        <td>密码:</td>
                        <td><input type="password" name="password">
                        </td>
                    </tr>
                </table>
            <br>
                <input type="submit" value="登录" style="color:#BC8F8F">
            </form>
            <form action="zhuce.jsp">
                <input type="submit" value="注册" style="color:#BC8F8F">
            </form>
    </center>
</body>
</html>

docker 容器替换其它源的最佳方式

No Comments 容器技术

启动
docker run -itd -p 808:8080  jefftomcat:v2 /bin/bash
看进程
docker ps
将apt/source.list复制到本地服务器

docker cp 容器ID:/容器目录  地本目录

docker cp 81128bff7253:/etc/apt/ tmp
 
编辑source.list文件
docker cp sources.list 81128bff7253:/etc/apt/
docker attach 81128bff7253
vim sources.list
复制回去
docker cp sources.list 81128bff7253:/etc/apt/
直接进去更新

docker attach 容器ID
docker attach 81128bff7253
  [email protected]:/usr/local/tomcat/bin#  apt-get update

内容如下
deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib

一看必会系统:创建基础镜像Create a base image

No Comments Linux

https://docs.docker.com/develop/develop-images/baseimages/#more-resources

 

试验如下:在centos7机器上做centos镜像

直接参考这个脚本

https://raw.githubusercontent.com/docker/docker/master/contrib/mkimage-yum.sh

./mkimage-yum.sh -y /etc/yum.conf centos7

执行如上脚本,成功后,就可以看到镜像了【docker images】,概要说明一下,主要是如下几步:

1.tmp目录下建立临时目录和文件系统

2.使用yum安装相关的软件包

3.软件包安装和信息定制

4.tar打包

5.清理

建立目录结构[rootfs]

target=(mktemp?d??tmpdir<?XML:NAMESPACE PREFIX = [default] http://www.w3.org/1998/Math/MathML NS = "http://www.w3.org/1998/Math/MathML" />(mktemp?d??tmpdir(basename $0).XXXXXX)

set -x

mkdir -m 755 "$target"/dev

mknod -m 600 "$target"/dev/console c 5 1

mknod -m 600 "$target"/dev/initctl p

mknod -m 666 "$target"/dev/full c 1 7

mknod -m 666 "$target"/dev/null c 1 3

mknod -m 666 "$target"/dev/ptmx c 5 2

mknod -m 666 "$target"/dev/random c 1 8

mknod -m 666 "$target"/dev/tty c 5 0

mknod -m 666 "$target"/dev/tty0 c 4 0

mknod -m 666 "$target"/dev/urandom c 1 9

mknod -m 666 "$target"/dev/zero c 1 5

# amazon linux yum will fail without vars set

if [ -d /etc/yum/vars ]; then

mkdir -p -m 755 "$target"/etc/yum

cp -a /etc/yum/vars "$target"/etc/yum/

fi

软件包安装和信息定制

yum -c "yumconfig"??installroot="yumconfig"??installroot="target" –releasever=/ –setopt=tsflags=nodocs \

    –setopt=group_package_types=mandatory -y groupinstall Core

yum -c "yumconfig"??installroot="yumconfig"??installroot="target" -y clean all

打包

tar –numeric-owner -c -C "target".|dockerimport?target".|dockerimport?name:$version

docker run -i -t name:name:version echo success

清理

rm -rf "$target"

如果我们需要自己的安全增强软件等定制,只需要在第2步将我们的内容合并进去即可

 

Most Dockerfiles start from a parent image. If you need to completely control the contents of your image, you might need to create a base image instead. Here’s the difference:

  • A parent image is the image that your image is based on. It refers to the contents of the FROM directive in the Dockerfile. Each subsequent declaration in the Dockerfile modifies this parent image. Most Dockerfiles start from a parent image, rather than a base image. However, the terms are sometimes used interchangeably.

  • A base image either has no FROM line in its Dockerfile, or has FROM scratch.

This topic shows you several ways to create a base image. The specific process will depend heavily on the Linux distribution you want to package. We have some examples below, and you are encouraged to submit pull requests to contribute new ones.

Create a full image using tar

In general, start with a working machine that is running the distribution you’d like to package as a parent image, though that is not required for some tools like Debian’s Debootstrap, which you can also use to build Ubuntu images.

It can be as simple as this to create an Ubuntu parent image:

$ sudo debootstrap xenial xenial > /dev/null
$ sudo tar -C xenial -c . | docker import - xenial

a29c15f1bf7a

$ docker run xenial cat /etc/lsb-release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04 LTS"

There are more example scripts for creating parent images in the Docker GitHub Repo:

Create a simple parent image using scratch

You can use Docker’s reserved, minimal image, scratch, as a starting point for building containers. Using the scratch “image” signals to the build process that you want the next command in the Dockerfile to be the first filesystem layer in your image.

While scratch appears in Docker’s repository on the hub, you can’t pull it, run it, or tag any image with the name scratch. Instead, you can refer to it in your Dockerfile. For example, to create a minimal container using scratch:

FROM scratch
ADD hello /
CMD ["/hello"]

Assuming you built the “hello” executable example by following the instructions at https://github.com/docker-library/hello-world/, and you compiled it with the -static flag, you can build this Docker image using this docker build command:

docker build --tag hello .

Don’t forget the . character at the end, which sets the build context to the current directory.

Note: Because Docker for Mac and Docker for Windows use a Linux VM, you need a Linux binary, rather than a Mac or Windows binary. You can use a Docker container to build it:

$ docker run --rm -it -v $PWD:/build ubuntu:16.04

container# apt-get update && apt-get install build-essential
container# cd /build
container# gcc -o hello -static -nostartfiles hello.c

To run your new image, use the docker run command:

docker run --rm hello

This example creates the hello-world image used in the tutorials. If you want to test it out, you can clone the image repo.

More resources

There are lots more resources available to help you write your Dockerfile.

docker Error response from daemon 解决

No Comments 容器技术

[[email protected] ~]# docker search ubantu

Error response from daemon: Get https://index.docker.io/v1/search?q=ubantu&n=25: x509: certificate has expired or is not yet valid

 

解决

vim /etc/chrony.conf   更新ntp服务器
systemctl restart chronyd
date
timedatectl set-timezone Asia/Shanghai  设置时区
date
chronyc sources -v   查看同步

以下为正常。即可使用docker search
[[email protected] ~]# chronyc sources -v
210 Number of sources = 1

  .– Source mode  ‘^’ = server, ‘=’ = peer, ‘#’ = local clock.
/ .- Source state ‘*’ = current synced, ‘+’ = combined , ‘-‘ = not combined,
| /   ‘?’ = unreachable, ‘x’ = time may be in error, ‘~’ = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) –.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample              
===============================================================================
^* 118.24.4.66                   2   6   377    62   -821us[-2454us] +/-   66ms
[[email protected] ~]#

一看必会系列:docker mysql 主从集群测试

No Comments 容器技术

 

仓库操作
docker pull mysql:5.6
docker images
docker tag docker.io/mysql 192.168.142.130:5000/mysql56:v2
docker tag 97fdbdd65c6a 192.168.142.130:5000/mysql56:v2
docker images
docker push 192.168.142.130:5000/mysql56:v2

主从服务器操作

docker run   –restart=always -p  3356:3306 –name masterdb -v  /db/mysqlCluster/master:/var/lib/mysql  -e  MYSQL_ROOT_PASSWORD=123456   -d  192.168.142.130:5000/mysql56:v2

docker run   –restart=always -p  3356:3306 –name slavedb -v  /db/mysqlCluster/master:/var/lib/mysql  -e  MYSQL_ROOT_PASSWORD=123456   -d  192.168.142.130:5000/mysql56:v2

进主服务器
docker exec -it masterdb /bin/bash
进从服务器
docker exec -it slavedb /bin/bash

apt-get update && apt-get install vim -y

进入容器修改配置文件
[[email protected] ~]# docker exec -it masterdb /bin/bash
[email protected]:/# vim /etc/mysql/mysql.conf.d/mysqld.cnf

主服务器配置
server-id = 1
log_bin = mysql-bin
lower_case_table_names=1

从服务器配置
server-id = 2
log_bin = mysql-bin
lower_case_table_names=1

[email protected]:/# mysql -u root -p      
Enter password:

主从服务器配置,实际这个权限给只读就行
GRANT REPLICATION SLAVE ON *.* TO ‘re’@’%’ IDENTIFIED BY ‘123456’;
flush privileges;

从服务器
注意端口
CHANGE MASTER TO MASTER_HOST=’192.168.142.130′,MASTER_USER=’re’, MASTER_PASSWORD=’123456′,MASTER_LOG_FILE=’mysql-bin.000001′, MASTER_LOG_POS=387, master_port=3356;
flush privileges;
start slave;

从服务器查看
mysql> show slave STATUS \G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.142.130
                  Master_User: re
                  Master_Port: 3356
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000001
          Read_Master_Log_Pos: 387
               Relay_Log_File: mysqld-relay-bin.000002
                Relay_Log_Pos: 283
        Relay_Master_Log_File: mysql-bin.000001
             Slave_IO_Running: Yes   —成功
            Slave_SQL_Running: Yes

从服务器建立普通帐号测试只读
GRANT select ON *.* TO ‘user01’@’%’ IDENTIFIED BY’123456′ WITH GRANT OPTION;

一小时Docker教程

No Comments 容器技术

 

Docker基础

这篇基础文章是方便用户在使用cSphere?#25945;?#20043;前,了解docker基础知识。

针对已经有一定的Linux基础知识的用户。

Docker是什么

Docker是一个改进的容器技术。具体的“改进”体现在,Docker为容器引入了镜像,使得容器可?#28304;?#39044;先定义好的模版(images)创建出来,并且这个模版?#25925;?#20998;层的。

Docker经常被提起的特点:

轻量,体现在内存?#21152;?#23567;,高密度
快速,毫秒启动
隔离,沙盒技术更像虚拟机
Docker技术的基础:

namespace,容器隔离的基础,保证A容器看不到B容器. 6个名空间:User,Mnt,Network,UTS,IPC,Pid
cgroups,容器资源统计和隔离。主要用到的cgroups子系统:cpu,blkio,device,freezer,memory
unionfs,典型:aufs/overlayfs,分层镜像实现的基础
Docker组件:

docker Client客户端————>向docker服务器进程发起请求,如:创建、停止、销毁容器等操作
docker Server服务器进程—–>处理所有docker?#37027;?#27714;,管理所有容器
docker Registry镜像仓库——>镜像存放的中央仓库,可看作是存放二进制的scm
Docker安装

Docker的安装非常简单,支持目前所有主流操作系统,从Mac到Windows到各种Linux发行版
具体参考: docker安装

Docker常见命令

容器相关操作

docker create # 创建一个容器但是不启动它
docker run # 创建并启动一个容器
docker stop # 停止容器运行,发送信号SIGTERM
docker start # 启动一个停止状态的容器
docker restart # 重启一个容器
docker rm # 删除一个容器
docker kill # 发送信号给容器,默认SIGKILL
docker attach # 连接(进入)到一个正在运行的容器
docker wait # 阻塞到一个容器,直到容器停止运行
获取容器相关信息

docker ps # 显示状态为运行(Up)的容器
docker ps -a # 显示所有容器,包括运行中(Up)的和退出的(Exited)
docker inspect # 深入容器内部获取容器所有信息
docker logs # 查看容器的日志(stdout/stderr)
docker events # 得到docker服务器的实时的事件
docker port # 显示容器的端口?#25104;?
docker top # 显示容器的进程信息
docker diff # 显示容器文件系统?#37027;?#21518;变化
导出容器

docker cp # 从容器里向外拷贝文件或目录
docker export # 将容器整个文件系统导出为一个tar包,不带layers、tag等信息
执行

docker exec # 在容器里执行一个命令,可以执行bash进入?#25442;?#24335;
镜像操作

docker images # 显示本地所有的镜像列表
docker import # 从一个tar包创建一个镜像,往往和export结合使用
docker build # 使用Dockerfile创建镜像(推荐)
docker commit # 从容器创建镜像
docker rmi # 删除一个镜像
docker load # 从一个tar包创建一个镜像,和save配合使用
docker save # 将一个镜像保存为一个tar包,带layers和tag信息
docker history # 显示生成一个镜像的历?#35775;?#20196;
docker tag # 为镜像起一个别名
镜像仓库(registry)操作

docker login # 登录到一个registry
docker search # 从registry仓库搜索镜像
docker pull # 从仓库下载镜像到本地
docker push # 将一个镜像push到registry仓库中
获取Container IP地址(Container状态必须是Up)

docker inspect id | grep IPAddress | cut -d ‘"’ -f 4
获取端口?#25104;?/p>

docker inspect -f ‘{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}’ id
获取环境变量

docker exec container_id env
杀掉所有正在运行的容器

docker kill $(docker ps -q)
删除?#31995;?一周前创建)容器

docker ps -a | grep ‘weeks ago’ | awk ‘{print $1}’ | xargs docker rm
删除已经停止的容器

docker rm `docker ps -a -q`
删除所有镜像,小心

docker rmi $(docker images -q)
Dockerfile

Dockerfile是docker构建镜像的基础,也是docker区别于其他容器的重要特征,正是有了Dockerfile,docker的自动化和可移植性才成为可能。

不论是开发?#25925;?#36816;维,学会编写Dockerfile几乎是必备的,这有助于你理解整个容器的运?#23567;?/p>

FROM , 从一个基础镜像构建新的镜像

FROM ubuntu
MAINTAINER , 维护者信息

MAINTAINER William <[email protected]>
ENV , 设置环境变量

ENV TEST 1
RUN , 非?#25442;?#24335;运行shell命令

RUN apt-get -y update
RUN apt-get -y install nginx
ADD , 将外部文件拷贝到镜像里,src可以为url

ADD http://nicescale.com/  /data/nicescale.tgz
WORKDIR /path/to/workdir, 设置工作目录

WORKDIR /var/www
USER , 设置用户ID

USER nginx
VULUME <#dir>, 设置volume

VOLUME [‘/data’]
EXPOSE , 暴露哪些端口

EXPOSE 80 443
ENTRYPOINT [‘executable’, ‘param1’,’param2’]执行命令

ENTRYPOINT ["/usr/sbin/nginx"]
CMD [“param1”,”param2”]

CMD ["start"]
docker创建、启动container时执行的命令,如果设置了ENTRYPOINT,则CMD将作为?#38382;?/p>

Dockerfile最佳实践

尽量将一些常用不变的指令放到前面
CMD和ENTRYPOINT尽量使用json数组方式
通过Dockerfile构建image

docker build csphere/nginx:1.7 .
镜像仓库Registry

镜像从Dockerfile build生成后,需要将镜像推送(push)到镜像仓库。企业内部都需要构建一个私有docker registry,这个registry可以看作二进制的scm,CI/CD也需要围绕registry进?#23567;?/p>

部署registry

mkdir /registry
docker run  -p 80:5000  -e STORAGE_PATH=/registry  -v /registry:/registry  registry:2.0
推送镜像保存到仓库

假设192.168.1.2是registry仓库的地址:

docker tag  csphere/nginx:1.7 192.168.1.2/csphere/nginx:1.7
docker push 192.168.1.2/csphere/nginx:1.7
几个简单小例子

容器操作

1.创建并拉取busybox

# docker run -it –name con01 busybox:latest
/ # ip addr    #容器里执行
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
Segmentation fault (core dumped)
/ # ping www.csphere.cn
PING www.csphere.cn (117.121.26.243): 56 data bytes
64 bytes from 117.121.26.243: seq=0 ttl=48 time=3.139 ms
64 bytes from 117.121.26.243: seq=1 ttl=48 time=3.027 ms
^C
— www.csphere.cn ping statistics —
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 3.027/3.083/3.139 ms
exit    #退出容器
2.创建测试容器

docker run -d –name con03 csphere/test:0.1
efc9bda4a2ff2f479b18e0fc4698e42c47c9583a24c93f5ce6b28a828a172709
3.登陆到con03中

# docker exec -it con03 /bin/bash
[[email protected] /]# exit
4.停止con03

# docker stop con03
con03
5.开启con03

# docker start con03
con03
6.删除con03

# docker ps -a
CONTAINER ID        IMAGE                    COMMAND                CREATED             STATUS                      PORTS                                             NAMES
efc9bda4a2ff        csphere/test:0.1         "/usr/local/bin/run    4 minutes ago       Up 17 seconds                                                                 con03              
99aa6ee25adc        busybox:latest           "/bin/sh"              14 minutes ago      Exited (0) 12 minutes ago                                                     con02              
831c93de9b9f        busybox:latest           "/bin/sh"              2 hours ago         Up 27 minutes                                                                 con01
# docker rm con02     #容器停止的状态
# docker rm -f con03  #容器开启的状态
镜像操作

1.从docker hub官方镜像仓库拉取镜像

# docker pull busybox:latest
atest: Pulling from busybox
cf2616975b4a: Pull complete
6ce2e90b0bc7: Pull complete
8c2e06607696: Already exists
busybox:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:38a203e1986cf79639cfb9b2e1d6e773de84002feea2d4eb006b52004ee8502d
Status: Downloaded newer image for busybox:latest
2.从本地上传镜像到镜像仓库

docker push 192.168.1.2/csphere/nginx:1.7
3.查找镜像仓库的某个镜像

# docker search centos/nginx
NAME                                     DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
johnnyzheng/centos-nginx-php-wordpress                                                   1                    [OK]
sergeyzh/centos6-nginx                                                                   1                    [OK]
hzhang/centos-nginx                                                                      1                    [OK]
4.查看本地镜像列表

# docker images
TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
docker.io/csphere/csphere   0.10.3              604c03bf0c9e        3 days ago          62.72 MB
docker.io/csphere/csphere   latest              604c03bf0c9e        3 days ago          62.72 MB
csphere/csphere             0.10.3              604c03bf0c9e        3 days ago          62.72 MB
registry                    2.0                 2971b6ce766c        7 days ago          548.1 MB
busybox                     latest              8c2e06607696        3 weeks ago         2.43 MB
5.删除镜像

docker rmi busybox:latest        #没有容器使用此镜像创建,如果有容器在使用此镜像会报错:Error response from daemon: Conflict, cannot delete 8c2e06607696 because the running container 831c93de9b9f is using it, stop it and use -f to force
FATA[0000] Error: failed to remove one or more images
docker rmi -f busybox:latest     #容器使用此镜像创建,此容器状态为Exited
6.查看构建镜像所用过的命令

# docker history busybox:latest
IMAGE               CREATED             CREATED BY                                      SIZE
8c2e06607696        3 weeks ago         /bin/sh -c #(nop) CMD ["/bin/sh"]               0 B
6ce2e90b0bc7        3 weeks ago         /bin/sh -c #(nop) ADD file:8cf517d90fe79547c4   2.43 MB
cf2616975b4a        3 weeks ago         /bin/sh -c #(nop) MAINTAINER Jér?me Petazzo     0 B
一小时Docker教程

一小时Docker教程

30选5玩法