加速Docker Pull或者docker-compose拉取镜像 - 适用github源

为github的docker源提速

下载zlib(github上的)非常幸苦,速度极慢

找到了大神的文章:加速docker pull

有什么用

为github的docker源提速,比如:

ghcr.io/zlib-searcher/zlib-searcher:latest

ghcr.io/puzzithinker/zlib-searcher:master

怎么用

  1. 配置http-proxy.conf
1
2
3
4
mkdir -p /etc/systemd/system/docker.service.d
vim /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://192.168.1.1:7890"
  1. 配置https-proxy.conf
1
2
3
4
5

vim /etc/systemd/system/docker.service.d/https-proxy.conf
[Service]
Environment="HTTPS_PROXY=http://192.168.1.1:7890"
#这个设置是难点,踩坑折腾了半小时左右,一直监控着clash.meta的UI,docker pull过程到底有没有走proxy,设置对了以后,速度果然一下子,嗖.....
  1. 重启服务
1
2
sudo systemctl daemon-reload
sudo systemctl restart docker
  1. 监控一下是否正常走了设置的代理

相关内容

灵感来源

https://zu1k.com/posts/coding/speedup-docker-pull/#%E4%B8%BAdocker%E8%AE%BE%E7%BD%AE%E4%BB%A3%E7%90%86

假如Docker image的源repository被删除了

1
2
3
4
5
6
7
8
9
10
You will need to save the Docker image as a tar file:

> docker save -o <path for generated tar file> <image name>
Then copy your image to a new system with regular file transfer tools such as cp, scp, or rsync (preferred for big files). After that you will have to load the image into Docker:

> docker load -i <path to image tar file>
You should add filename (not just directory) with -o, for example:

> docker save -o c:/myfile.tar centos:16
PS: You may need to sudo all commands.

https://stackoverflow.com/questions/23935141/how-to-copy-docker-images-from-one-host-to-another-without-using-a-repository

将docker内文件拷贝到本地文件夹内

  docker cp 容器Id或name:容器内路径 本地文件夹路径
  docker cp containername:/usr/share/nginx/html /volume2/KingchuxingSSD512G/docker/compose/it-tools/html

反之亦然