首先,查找原因
1.先看srs服务在哪
find / -type f -name srs 2>/dev/null
运行结果:
/var/lib/docker/overlay2/5347867cc0ffed43f1ae24eba609637bfa3cc7cf5f8c660976d2286fa6a88d2b/diff/usr/local/srs/objs/srs
/var/lib/docker/overlay2/5347867cc0ffed43f1ae24eba609637bfa3cc7cf5f8c660976d2286fa6a88d2b/diff/usr/local/srs/etc/init.d/srs
/var/lib/docker/overlay2/1055a7db13201f6d360446bb7e82cd1af5149547b96d906430ac5780bfb12b8b/diff/usr/local/srs/objs/srs
/var/lib/docker/overlay2/1055a7db13201f6d360446bb7e82cd1af5149547b96d906430ac5780bfb12b8b/diff/usr/local/srs/etc/init.d/srs
2.查看所有docker应用
docker ps -a
运行结果:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f26ee488e3d4 registry.cn-hangzhou.aliyuncs.com/ossrs/srs-stack:v5.12.17 "./bootstrap" 7 minutes ago Created srs-stack
fc4fa444888d tiangolo/nginx-rtmp "nginx -g 'daemon of…" 2 hours ago Exited (0) 7 minutes ago dk_rtmp-nginx-rtmp-1
找打了name为srs-stack的应用
3.在docker里面运行srs
docker start srs-stack
运行结果:
Error response from daemon: driver failed programming external connectivity on endpoint srs-stack (e14ce5129c6c3068f14bbbb406cb3688bc8232238e3dc290d3650ad114b69252): Error starting userland proxy: listen tcp4 0.0.0.0:8080: bind: address already in use
Error: failed to start containers: srs-stack片
找到原因了,端口8080被占用
4.修改修改占用端口,我的是frp的 vhost_http_port=8080占用了,我将它注释掉
# vhost_http_port=8080
每个人根据自己的服务进程修改掉占用端口的程序即可
再次启动
docker start srs-stack
报错:
Error response from daemon: driver failed programming external connectivity on endpoint srs-stack (2f9ade46a5f6d4b971622986c8304b34488c0a5440082a190a190f1a4467cba9): Bind for 0.0.0.0:1935 failed: port is already allocated
5.修改配置文件docker-compose.yml,首先查找该文件
find / -name docker-compose.yml 2>/dev/null
运行结果:
/www/dk_project/dk_app/dk_rtmp/docker-compose.yml
用ftp工具下载该配置文件,打开,内容如下:
version: '3'
services:nginx-rtmp:image: tiangolo/nginx-rtmpports:- ${RTMP_PORT}:1935volumes:- ./data:/datarestart: unless-stopped
将1935改成1936
6.修改.env文件
在相同目录下可以找到,同样的,下载打开
RTMP_PORT=1935
RTMP_PATH=/www/dk_project/dk_app/dk_rtmp
将1935改成1936
7.执行修改
cd /www/dk_project/dk_app/dk_rtmp
docker-compose down
docker-compose up -d
8.再次运行srs-stack
docker start srs-stack
没有报错,结果如下:
[root@VM-0-14-tencentos dk_rtmp]# docker start srs-stack
srs-stack
再去启动看看,启动成功!
进入后台管理面板,成功~