加速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

反之亦然


NAS中无法使用该文方案

失败错误:

1
2
3
ERROR: error pulling image configuration: Get "https://production.cloudflare.docker.com/registry-v2/docker
/registry/v2/blobs/sha256/fe/fe9002effde28797931563f042679ea1e505026f90ddbd737ba9cc3d425f7b3a/data?verify=
1719848198-tPisG8yWTSP%2FS87aF2Ea40NhcOk%3D": dial tcp 157.240.12.35:443: i/o timeout

环境NAS中 docker pull alfg/nginx-rtmp

docker pull 如何走代理?

执行像上面那样的步骤

sudo systemctl daemon-reload
sudo systemctl restart docker

1
2
sudo systemctl restart docker           
Failed to restart docker.service: Unit docker.service failed to load: No such file or directory.

暂时放弃了该NAS中的docker,目前无法解决这个错误。(等待第二天自动重启后查看状态)

  • 切换到debian中可以正常pull(已经打了这个‘补丁’)

    /www/server/panel/data/compose/

  • 或者 在docker-compose文件中 使用国内可用的镜像地址

    • 比如:registry.cn-hangzhou.aliyuncs.com/ossrs/srs:5

Docker 通过ffmpeg将rtsp转码为rtmp进行播放

整个流程说明:rtsp转rtmp直播.md

切换docker镜像到docker run -d -p 1935:1935 -p 8080:8080 alqutami/rtmp-hls

1
2
3
4
5
6
7
version: "3"
services:
rtmp-hls:
ports:
- 1935:1935
- 8113:8080
image: alqutami/rtmp-hls

配置 nginx-hls.conf

1
2
nginx-hls.conf
....

是否需要做配置?

上面这个方案的docker pull成功,但是无法正常启动;切换:

1
2
3
4
5
6
7
8
9
10
11
12
version: "3"
services:
rtmp-hls:
ports:
- 1935:1935
- 8113:8080
image: polinux/rtmp-hls



推流
ffmpeg -i "rtsp://admin:dahua123@192.168.6.126:554" -f flv -r 25 -an rtmp://192.168.6.116:1935/live/test

image-20240702082940511

image-20240702090326679

推流

1
ffmpeg -i "rtsp://a:a@192.168.6.126:554" -f flv -r 25 -an rtmp://192.168.6.116:1935/stream/test

使用镜像自带的players播放

  • To play RTMP content (requires Flash): http://localhost:8080/players/rtmp.html
  • To play HLS content: http://localhost:8080/players/hls.html
  • To play HLS content using hls.js library: http://localhost:8080/players/hls_hlsjs.html
  • To play DASH content: http://localhost:8080/players/dash.html
  • To play RTMP and HLS contents on the same page: http://localhost:8080/players/rtmp_hls.html

个性化需求沟通 扫客服加V加群: