# 镜像管理

````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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET 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?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
