LIANTIAN's LOG

水底渐干,月渐满...

0%

https://github.com/liantian-cn/liantian-cn.github.io/tree/master/2020/smokeping.docker

遇到两个之前没遇到的问题。

  1. 如果有两个进程需要启动,怎么办。
    用supervisor
  2. lighttpd nginx apache怎么选
    本来没啥可想的,可试了一圈,搭配传统cgi (perl),还是lighttpd最好用。

生成打包,导入命令如下
文件在https://github.com/liantian-cn/liantian-cn.github.io/tree/master/2020/smokeping.docker

1
2
3
4
5
6
7
8
9
10
docker build --tag smokeping:2.7.3-r3 .

docker create -p 32080:32080 -v /DATA/config/smokeping.conf:/etc/smokeping/config --restart always --name SmokePing smokeping:2.7.3-r3
docker export SmokePing > SmokePing.2.7.3-r3.export.tar
docker start SmokePing

docker import SmokePing.2.7.3-r3.export.tar smokeping:2.7.3-r3
docker create -p 32080:32080 -v /DATA/config/smokeping.conf:/etc/smokeping/config --restart always --name SmokePing smokeping:2.7.3-r3 /usr/bin/supervisord


安装Docker

参考https://mirror.tuna.tsinghua.edu.cn/help/docker-ce/

加源、傻瓜安装 apt-get install docker-ce

赋予当前用户用docker的权限

sudo usermod -aG docker $USER

需要重启docker服务,重登user生效。

两个dockerfile

Dockerfile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
FROM alpine:latest

ENV TZ=Asia/Shanghai
COPY ./qbittorrent /

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
&& apk update \
&& apk upgrade \
&& apk add --no-cache ca-certificates tzdata python3 bash nano openssl \
&& rm -rf /var/cache/apk/* \
&& chmod a+x /usr/local/bin/qbittorrent-nox \
&& mkdir -p ~/.config/qBittorrent/ssl \
&& cd ~/.config/qBittorrent/ssl \
&& openssl req -new -newkey rsa:4096 -x509 -nodes -days 7300 -subj "/C=CC/ST=ST/L=LL/O=Dis/CN=qbittorrent.home.local" -out server.crt -keyout server.key \
&& echo "[Preferences]" >> /root/.config/qBittorrent/qBittorrent.conf \
&& echo "Bittorrent\AutoUpdateTrackers=true" >> /root/.config/qBittorrent/qBittorrent.conf \
&& echo "Bittorrent\CustomizeTrackersListUrl=https://trackerslist.com/all.txt" >> /root/.config/qBittorrent/qBittorrent.conf \
&& echo "WebUI\Port=8080" >> /root/.config/qBittorrent/qBittorrent.conf \
&& echo "WebUI\HTTPS\CertificatePath=/root/.config/qBittorrent/ssl/server.crt" >> /root/.config/qBittorrent/qBittorrent.conf \
&& echo "WebUI\HTTPS\KeyPath=/root/.config/qBittorrent/ssl/server.key" >> /root/.config/qBittorrent/qBittorrent.conf \
&& echo "WebUI\HTTPS\Enabled=false" >> /root/.config/qBittorrent/qBittorrent.conf


VOLUME /DATA

EXPOSE 8080 8443 9068 9068/udp


CMD [ "/usr/local/bin/qbittorrent-nox" ]

Dockerfile.build

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
FROM alpine:latest
WORKDIR /root/

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
&& apk update \
&& apk upgrade \
&& apk add --no-cache ca-certificates make g++ gcc qt5-qtsvg-dev boost-dev qt5-qttools-dev file wget unzip tar

# 墙内下不动,改为拷贝
# RUN wget https://github.com/arvidn/libtorrent/releases/download/libtorrent_1_2_7/libtorrent-rasterbar-1.2.7.tar.gz
# RUN wget https://github.com/c0re100/qBittorrent-Enhanced-Edition/archive/release-4.2.5.11.zip
COPY libtorrent-rasterbar-1.2.7.tar.gz .
COPY qBittorrent-Enhanced-Edition-release-4.2.5.11.zip .

RUN cd /root \
&& tar -zxvf libtorrent-rasterbar-1.2.7.tar.gz \
&& cd libtorrent-rasterbar-1.2.7 \
&& ./configure --host=x86_64-alpine-linux-musl \
&& make -j$(nproc) install-strip


RUN cd /root \
&& unzip qBittorrent-Enhanced-Edition-release-4.2.5.11.zip \
&& cd qBittorrent-Enhanced-Edition-release-4.2.5.11/ \
&& ./configure --disable-gui --host=x86_64-alpine-linux-musl \
&& make -j$(nproc) install

RUN ldd /usr/local/bin/qbittorrent-nox |cut -d ">" -f 2|grep lib|cut -d "(" -f 1|xargs tar -chvf /root/qbittorrent.tar \
&& mkdir /qbittorrent \
&& tar -xvf /root/qbittorrent.tar -C /qbittorrent \
&& cp --parents /usr/local/bin/qbittorrent-nox /qbittorrent

脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
docker build --no-cache -t qbittorrentee:build . -f Dockerfile.build
docker create --name extract qbittorrentee:build
docker cp extract:/qbittorrent .
docker rm -f extract

docker build --no-cache -t qbittorrentee:4.2.5.11 .


docker create -p 8080:8080 -p 8443:8443 -p 9068:9068 -p 9068:9068/udp -v /DATA:/DATA --restart always --name qBittorrentEE qbittorrentee:4.2.5.11 /usr/local/bin/qbittorrent-nox

docker start qBittorrentEE


docker stop qBittorrentEE
docker rm qBittorrentEE
docker rmi qbittorrentee:4.2.5.11


docker export qBittorrentEE > qBittorrentEE.export.4.2.5.11.tar

docker import qBittorrentEE.export.4.2.5.11.tar qbittorrentee:4.2.5.11

docker create -p 8080:8080 -p 8443:8443 -p 9068:9068 -p 9068:9068/udp -v /DATA:/DATA --restart always --name qBittorrentEE qbittorrentee:4.2.5.11 /usr/local/bin/qbittorrent-nox