docker nginx镜像自定义启动脚本不能运行

    技术2022-07-17  72

    原有nginx镜像中CMD是,如下图

    如果想自定义启动脚本, 最终在启动nginx

    以下是自定义脚本内容:特别注意nginx的启动和原有启动保持一致

    官方解释

    If you add a custom CMD in the Dockerfile, be sure to include -g daemon off; in the CMD in order for nginx to stay in the foreground, so that Docker can track the process properly (otherwise your container will stop immediately after starting)! 如果你在Dockerfile中添加了一个自定义CMD,一定要关闭-g守护进程; 为了让nginx留在前台, 这样Docker就可以正确地跟踪进程(否则你的容器会在启动后立即停止)!

     

    Processed: 0.009, SQL: 9