> For the complete documentation index, see [llms.txt](https://lzcloudsecurity.gitbook.io/yun-an-quan-gong-fang-ru-men/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lzcloudsecurity.gitbook.io/yun-an-quan-gong-fang-ru-men/di-liu-zhang-yun-yuan-sheng-gong-fang/docker-ji-chu-ru-men/jing-xiang-guan-li.md).

# 镜像管理

````bash
```#查看镜像分层历史
docker image history nginx
 
#镜像详细
docker image inspect nginx
 
#导出镜像
docker save nginx -o nginx.tar
docker save mysql > /data/mysql.tar
 
#导入镜像
docker load -i /data/mysql.tar
docker load < /data/mysql.tar
 
#删除镜像
docker rmi ID
docker rmi NAME
 
#打标签
docker tag alpine alpine:3.11
 
#镜像下载保存路径
/var/lib/docker/overlay2/
````

**Alpine基础镜像**

* &#x20;Alpine是一个面向安全的轻型Linux发行版,关注安全,性能和资源效能.是一个适用生产基础系统/环境.
* &#x20;Alpine提供了自己的包管理工具apk,通过apk直接查询和安装各种软件 .

```bash
#Alpine官方镜像
https://hub.docker.com/_/alpine/
 
#Alpine阿里云镜像仓库
https://mirrors.aliyun.com/alpine/
#修改阿里云更新源
vi /etc/apk/repositories
http://mirrors.aliyun.com/alpine/v3.8/main/
http://mirrors.aliyun.com/alpine/v3.8/community/
 
#更新源
apk update
 
#安装软件
apk add vim
 
#删除软件
apk del vim
 
#查看软件配置文件
apk manifest nginx
 
#基础包
apk add procps #提供top,ps,free
apk add psmisc #提供pstree,killall
apk add iputils-ping #提供ping
apk add net-tools #提供netstat网络工具
```

**镜像加速**

{% embed url="<https://cr.console.aliyun.com/>" %}

```bash
#通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
 
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://xxxx.mirror.aliyuncs.com"]
}
EOF
 
#重启
systemctl daemon-reload
systemctl restart docker
```
