容器互相访问,可不开放443端口。以免与其他应用冲突。
如需在局域网内其他设备使用,如macvlan容器、win电脑等,则需要开端口。修改compose文件注释即可。
git clone https://github.com/AisukaYuki/iyuuproxy.git
cd ./iyuuproxy
#运行iyuuproxy容器
docker-compose up -d
#查看ip命令,也可在各docker管理器查看
docker inspect iyuuproxy | grep IPAddress
shell输出:
"SecondaryIPAddresses": null,
"IPAddress": "",
"IPAddress": "172.29.0.2",
如上ip为 172.29.0.2,测试是否生效:
curl -k --resolve 'api.iyuu.cn:443:172.29.0.2' https://api.iyuu.cn
#返回json内容则成功
{"ret":200,"data":{"title":"Welcome IYUU","time":1705208847,"ip":"192.168.0.1","userAgent":"curl\/7.81.0","group":"QQ群:859882209, 931954050, 924099912, 586608623"},"msg":"","version":"2.0.0"}
修改iyuuplus的compose文件添加extra_hosts参数后重建,如:
version: '3.4'
services:
iyuuplus:
container_name: iyuuplus
image: iyuucn/iyuuplus:latest
extra_hosts:
- "api.iyuu.cn:172.29.0.2"
ports:
- 8787:8787
volumes:
- ./db:/IYUU/db
restart: unless-stopped
或修改容器内 /etc/hosts 添加172.29.0.2 api.iyuu.cn
docker exec -it <容器ID或容器名称> /bin/sh -c 'echo "172.29.0.2 api.iyuu.cn" >> /etc/hosts'
#此方法容器重启后需要重新执行,建议添加外部挂载文件替换容器的/etc/hosts。重启容器不会失效。
docker cp ./iyuu.crt <容器ID或容器名称>:/usr/local/share/ca-certificates/iyuu.crt
docker exec -it <容器ID或容器名称> /bin/sh -c 'update-ca-certificates'