<small id='p25mZ'></small><noframes id='p25mZ'>

<tfoot id='p25mZ'></tfoot>

      <bdo id='p25mZ'></bdo><ul id='p25mZ'></ul>

    1. <legend id='p25mZ'><style id='p25mZ'><dir id='p25mZ'><q id='p25mZ'></q></dir></style></legend>

        <i id='p25mZ'><tr id='p25mZ'><dt id='p25mZ'><q id='p25mZ'><span id='p25mZ'><b id='p25mZ'><form id='p25mZ'><ins id='p25mZ'></ins><ul id='p25mZ'></ul><sub id='p25mZ'></sub></form><legend id='p25mZ'></legend><bdo id='p25mZ'><pre id='p25mZ'><center id='p25mZ'></center></pre></bdo></b><th id='p25mZ'></th></span></q></dt></tr></i><div id='p25mZ'><tfoot id='p25mZ'></tfoot><dl id='p25mZ'><fieldset id='p25mZ'></fieldset></dl></div>
      1. 在 NGINX docker 容器中启动之前运行 bash 脚本

        时间:2023-09-06
        <legend id='83ROk'><style id='83ROk'><dir id='83ROk'><q id='83ROk'></q></dir></style></legend>

          <small id='83ROk'></small><noframes id='83ROk'>

            <bdo id='83ROk'></bdo><ul id='83ROk'></ul>
              <tbody id='83ROk'></tbody>

            1. <i id='83ROk'><tr id='83ROk'><dt id='83ROk'><q id='83ROk'><span id='83ROk'><b id='83ROk'><form id='83ROk'><ins id='83ROk'></ins><ul id='83ROk'></ul><sub id='83ROk'></sub></form><legend id='83ROk'></legend><bdo id='83ROk'><pre id='83ROk'><center id='83ROk'></center></pre></bdo></b><th id='83ROk'></th></span></q></dt></tr></i><div id='83ROk'><tfoot id='83ROk'></tfoot><dl id='83ROk'><fieldset id='83ROk'></fieldset></dl></div>

              • <tfoot id='83ROk'></tfoot>

                  本文介绍了在 NGINX docker 容器中启动之前运行 bash 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试使用 docker 在 localhost:8000 上运行 javascript 应用程序.我想做的一部分是根据 docker run 命令换出一些配置文件,我想将环境变量传递到容器中,以便 bash 脚本可以将其用作参数.

                  I'm trying to run a javascript app on localhost:8000 using docker. Part of what I would like to do is swap out some config files based on the docker run command, I'd like to pass an environment variable into the container so that the bash script can use that as a parameter.

                  我的 dockerfile 是这样的:

                  What my dockerfile is looking like is this:

                  FROM nginx
                  COPY . /usr/share/nginx/html
                  CMD ["bash","/usr/share/nginx/html/runfile.sh"]
                  

                  bash 脚本如下所示:

                  And the bash script looks like this:

                  #!/bin/bash
                  if [ "$SECURITY_VERSION" = "OPENAM" ]; then
                      sed -i -e 's/localhost/openam/g' authConfig.js
                  fi
                  
                  docker run -p 8000:80 missioncontrol:latest -e SECURITY_VERSION="TEST"
                  

                  Docker 给我一个异常说 -e exec command not found.

                  Docker gives me an exception saying -e exec command not found.

                  但是,如果我将 dockerfile 更改为使用 ENTRYPOINT 而不是 CMD,则 -e 标志有效,但网络服务器无法启动.

                  However if I change the dockerfile to use ENTRYPOINT instead of CMD, the -e flag works but the webserver does not start up.

                  这里有什么我遗漏的吗?ENTRYPOINT 是被覆盖还是什么?

                  Is there something I'm missing here? Is the ENTRYPOINT being overriden or something?

                  所以我更新了我的 dockerfile 以使用 ENTRYPOINT ["bash","/usr/share/nginx/html/runfile.sh", ";", " nginx -g daemon off;"]

                  So I've updated my dockerfile to use ENTRYPOINT ["bash","/usr/share/nginx/html/runfile.sh", ";", " nginx -g daemon off;"]

                  但是 docker 容器仍然关闭.我有什么遗漏吗?

                  But the docker container still shuts down. Is there something I'm missing?

                  推荐答案

                  NGINX 1.19 在根目录下有一个文件夹 /docker-entrypoint.d 放置由docker-执行的启动脚本entrypoint.sh 脚本.您还可以阅读日志上的执行情况.

                  NGINX 1.19 has a folder /docker-entrypoint.d on the root where place startup scripts executed by thedocker-entrypoint.sh script. You can also read the execution on the log.

                  /docker-entrypoint.sh:/docker-entrypoint.d/不为空,会尝试执行配置

                  /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration

                  /docker-entrypoint.sh:在其中寻找 shell 脚本/docker-entrypoint.d/

                  /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/

                  /docker-entrypoint.sh:正在启动

                  /docker-entrypoint.sh: Launching

                  [........]

                  /docker-entrypoint.sh:配置完成;准备启动

                  /docker-entrypoint.sh: Configuration complete; ready for start up

                  这篇关于在 NGINX docker 容器中启动之前运行 bash 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  <tfoot id='b9vRV'></tfoot>
                • <small id='b9vRV'></small><noframes id='b9vRV'>

                  • <bdo id='b9vRV'></bdo><ul id='b9vRV'></ul>
                    <legend id='b9vRV'><style id='b9vRV'><dir id='b9vRV'><q id='b9vRV'></q></dir></style></legend>
                      <tbody id='b9vRV'></tbody>

                          <i id='b9vRV'><tr id='b9vRV'><dt id='b9vRV'><q id='b9vRV'><span id='b9vRV'><b id='b9vRV'><form id='b9vRV'><ins id='b9vRV'></ins><ul id='b9vRV'></ul><sub id='b9vRV'></sub></form><legend id='b9vRV'></legend><bdo id='b9vRV'><pre id='b9vRV'><center id='b9vRV'></center></pre></bdo></b><th id='b9vRV'></th></span></q></dt></tr></i><div id='b9vRV'><tfoot id='b9vRV'></tfoot><dl id='b9vRV'><fieldset id='b9vRV'></fieldset></dl></div>