微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐