1.精简系统镜像:去掉不用的临时文件;
如下:将linux所有文件打包成system.tar,保存在tmp目录下,排除掉一些不需要的目录,不要将最后面有一个点给忘记了。
tar -cvpf /tmp/system.tar –directory=/ –exclude=proc –exclude=sys –exclude=dev –exclude=run –exclude=boot –exclude=data/mysql –exclude=home/tools .
导入docker:
2.docker import system.tar
查看镜像打标签:
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
没删文件太大了。
打标签:
root@localhost /tmp]$docker tag e0b4817f3b9b test/centos:test
[root@localhost /tmp]$docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test/centos test e0b4817f3b9b About a minute ago 17.4GB
rancher/rancher stable cb636b91766c 2 months ago 1.88GB
nginx latest 593aee2afb64 2 months ago 187MB
jary/centos test adff09de92c5 2 months ago 204MB
debian v2 11c8539d067c 2 months ago 215MB
debain v1 78242ca1986c 2 months ago 215MB
vimcentos v1 3338b2f1ac19 2 months ago 302MB
运行docker:
docker run -it e0b4817f3b9b /bin/bash
[root@a1a40c20a2c0 data]# ll
total 943016
drwxr-xr-x. 3 root root 75 Jan 10 16:51 backup
drwxr-xr-x. 2 root root 19 Nov 7 14:57 docker
drwxr-xr-x. 3 root root 19 Oct 19 14:53 log
进去查看保留的文件还在的。