docker里面设置ssh服务与supervisor随容器启动
作者:互联网
1. 新建dockerfile文件夹,有两个文件如下
docker_file/
├── Dockerfile
└── start.sh
2. start.sh中写需要启动运行的shell脚本
#!/bin/bash
service ssh start
supervisord -c /etc/supervisor/supervisord.conf
/bin/bash
3. Dockerfile中把shell copy进去
#!/bin/bash
service ssh start
supervisord -c /etc/supervisor/supervisord.conf
/bin/bash
gzfs@gzfs-gpu:~/creative_tools_fastapi_project/docker_file$ cat Dockerfile
FROM creative_tools_fastapi:v1
COPY ["start.sh", "/home/start.sh"]
WORKDIR /home
CMD ["sh", "/home/start.sh"]
4. build 镜像
docker build -t creative_tools_fastapi:latest .
5.启动容器
注意这里不能跟/bin/bash因为会覆盖前面的CMD命令
docker run -itd --restart=on-failure --name creative_tools_fastapi -p 8100:6100 -p 8200:6200 -p 8022:22 -v /mnt:/mnt creative_tools_fastapi:latest
标签:bin,supervisor,creative,start,sh,ssh,docker,tools,bash 来源: https://blog.csdn.net/HELLOWORLD2424/article/details/116207007