镜像加速配置

/etc/docker/daemon.json

cat <<EOF > /etc/docker/daemon.json
{
  "registry-mirrors": [
    "https://hub-mirror.c.163.com/",
    "https://dockerhub.icu",
    "https://doublezonline.cloud",
    "https://docker.m.daocloud.io"
  ],
  "insecure-registries": []
}
EOF

systemctl restart docker

pull nginx:alpine镜像

[root@bolog ~]# docker pull nginx:alpine
alpine: Pulling from library/nginx
46b060cc2620: Pull complete 
21af147d2ad5: Pull complete 
b3ee43e51ca6: Pull complete 
b17a9d410da1: Pull complete 
542e3e75411d: Pull complete 
2b2faad386df: Pull complete 
a5e22afba545: Pull complete 
fb923a41dc10: Pull complete 
Digest: sha256:208b70eefac13ee9be00e486f79c695b15cef861c680527171a27d253d834be9
Status: Downloaded newer image for nginx:alpine
docker.io/library/nginx:alpine

运行Nginx容器并安装tree

docker run -it --name nginx nginx:alpine sh
/ # vi /etc/apk/repositories 
#删除内容修改为
http://mirrors.aliyun.com/alpine/v3.19/main
http://mirrors.aliyun.com/alpine/v3.19/community

/ # apk update
fetch http://mirrors.aliyun.com/alpine/v3.19/main/x86_64/APKINDEX.tar.gz
fetch http://mirrors.aliyun.com/alpine/v3.19/community/x86_64/APKINDEX.tar.gz
v3.19.3-13-ge6ea13a261f [http://mirrors.aliyun.com/alpine/v3.19/main]
v3.19.3-12-g0fedf4c554c [http://mirrors.aliyun.com/alpine/v3.19/community]
OK: 23037 distinct packages available
/ # apk add tree
(1/1) Installing tree (2.1.1-r0)
Executing busybox-1.36.1-r19.trigger
OK: 46 MiB in 67 packages
/ # exit

提交为副本:nginx:v1

[root@bolog ~]# docker commit d58577d7d517 nginx:v1
sha256:ce6cde96bb9450db9a079d5db657ba3dbb937afea5b1fd25ea237e5404ccd17d
[root@bolog ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED              SIZE
nginx        v1        ce6cde96bb94   About a minute ago   46.2MB
nginx        alpine    1ae23480369f   5 weeks ago          43.2MB