久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

    <small id='4P35m'></small><noframes id='4P35m'>

      <bdo id='4P35m'></bdo><ul id='4P35m'></ul>

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

      使用'docker stop'和官方java圖像的java進程沒有

      SIGTERM not received by java process using #39;docker stop#39; and the official java image(使用docker stop和官方java圖像的java進程沒有收到SIGTERM)
        <legend id='VUW1Y'><style id='VUW1Y'><dir id='VUW1Y'><q id='VUW1Y'></q></dir></style></legend>

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

      1. <small id='VUW1Y'></small><noframes id='VUW1Y'>

            • <tfoot id='VUW1Y'></tfoot>

              • <bdo id='VUW1Y'></bdo><ul id='VUW1Y'></ul>
                  <tbody id='VUW1Y'></tbody>
                本文介紹了使用'docker stop'和官方java圖像的java進程沒有收到SIGTERM的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在使用基于 debian/jessie 的圖像 java:7u79 在 Docker 容器中運行 dropwizard Java 應用程序.

                I am running a dropwizard Java application in a Docker container using the image java:7u79 based on debian/jessie.

                我的 Java 應用程序處理 SIGTERM 信號以正常關閉.當我在沒有 Docker 的情況下運行應用程序時,SIGTERM 處理非常完美.

                My Java application handles the SIGTERM signal to shutdown gracefully. The SIGTERM handling works perfect when I run the application without Docker.

                當我在 Docker 容器中運行它時,當我發出 docker stop 命令時,SIGTERM 不會到達 Java 應用程序.它會在 10 秒后突然終止進程.

                When I run it in a Docker container the SIGTERM does not reach the Java application when I issue a docker stop command. It kills the process abruptly after 10 seconds.

                我的Dockerfile:

                FROM java:7u79
                
                COPY dropwizard-example-1.0.0.jar /opt/dropwizard/
                COPY example.keystore /opt/dropwizard/
                COPY example.yml /opt/dropwizard/
                
                WORKDIR /opt/dropwizard
                
                RUN java -jar dropwizard-example-1.0.0.jar db migrate /opt/dropwizard/example.yml
                
                CMD java -jar dropwizard-example-1.0.0.jar server /opt/dropwizard/example.yml
                
                EXPOSE 8080 8081
                

                這個 Dockerfile 有什么問題?有沒有其他方法可以解決這個問題?

                What is wrong with this Dockerfile? Is there any other way to tackle this problem?

                推薦答案

                假設您通過在 Dockerfile 中定義以下內容來啟動 Java 服務:

                Assuming you launch a Java service by defining the following in your Dockerfile:

                CMD java -jar ...
                

                當您現在進入容器并列出進程時,例如通過 docker exec -it <containerName>ps AHf (我沒有嘗試使用 java 而是使用 ubuntu 圖像)您會看到您的 Java 進程不是根進程(不是進程PID 1) 但 /bin/sh 進程的子進程:

                When you now enter the container and list the processes e.g. by docker exec -it <containerName> ps AHf (I did not try that with the java but with the ubuntu image) you see that your Java process is not the root process (not the process with PID 1) but a child process of a /bin/sh process:

                UID        PID  PPID  C STIME TTY          TIME CMD
                root         1     0  0 18:27 ?        00:00:00 /bin/sh -c java -jar ...
                root         8     1  0 18:27 ?        00:00:00   java -jar ...
                

                所以基本上你有一個 Linux shell,它是 PID 1 的主進程,它有一個 PID 8 的子進程 (Java).

                So basically you have a Linux shell that is the main process with PID 1 which has a child process (Java) with PID 8.

                要使信號處理正常工作,您應該避免使用那些 shell 父進程.這可以通過使用內置的 shell 命令 exec 來完成.這將使子進程接管父進程.所以最后以前的父進程不再存在.并且子進程成為 PID 為 1 的進程.在 Dockerfile 中嘗試以下操作:

                To get signal handling working properly you should avoid those shell parent process. That can be done by using the builtin shell command exec. That will make the child process taking over the parent process. So at the end the former parent process does not exist any more. And the child process becomes the process with the PID 1. Try the following in your Dockerfile:

                CMD exec java -jar ...
                

                然后進程列表應該顯示如下:

                The process listing then should show something like:

                UID        PID  PPID  C STIME TTY          TIME CMD
                root         1     0  0 18:30 ?        00:00:00 java -jar ...
                

                現在你只有一個 PID 為 1 的進程.一般來說,一個好的做法是讓 docker 容器只包含一個進程 - PID 為 1 的那個(或者如果你真的需要更多進程,那么你應該使用例如 supervisord 作為 PID 1,它自己負責子進程的信號處理).

                Now you only have that one process with PID 1. Generally a good practice is to have docker containers only contain one process - the one with PID 1 (or if you really need more processes then you should use e.g. supervisord as PID 1 which itself takes care of signal handling for its child processes).

                通過該設置,Java 進程將直接處理 SIGTERM.中間沒有任何 shell 進程可以中斷信號處理.

                With that setup the SIGTERM will be treated directly by the Java process. There is no shell process any more in between which could break signal handling.

                編輯:

                同樣的 exec 效果可以通過使用不同的 CMD 語法來實現(感謝 Andy 發表評論):

                The same exec effect could be achieved by using a different CMD syntax that does it implicitly (thanks to Andy for his comment):

                CMD ["java", "-jar", "..."]
                

                這篇關于使用'docker stop'和官方java圖像的java進程沒有收到SIGTERM的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                How to convert Integer to int?(如何將整數轉換為整數?)
                How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                Inconsistent behavior on java#39;s ==(java的行為不一致==)
                Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)
              • <small id='jlqub'></small><noframes id='jlqub'>

                <i id='jlqub'><tr id='jlqub'><dt id='jlqub'><q id='jlqub'><span id='jlqub'><b id='jlqub'><form id='jlqub'><ins id='jlqub'></ins><ul id='jlqub'></ul><sub id='jlqub'></sub></form><legend id='jlqub'></legend><bdo id='jlqub'><pre id='jlqub'><center id='jlqub'></center></pre></bdo></b><th id='jlqub'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='jlqub'><tfoot id='jlqub'></tfoot><dl id='jlqub'><fieldset id='jlqub'></fieldset></dl></div>
                • <bdo id='jlqub'></bdo><ul id='jlqub'></ul>
                  1. <tfoot id='jlqub'></tfoot>

                      <tbody id='jlqub'></tbody>
                  2. <legend id='jlqub'><style id='jlqub'><dir id='jlqub'><q id='jlqub'></q></dir></style></legend>

                        1. 主站蜘蛛池模板: 国产精品久久久久久婷婷天堂 | 色一情一乱一伦一区二区三区 | 一区二区三区观看视频 | 国产欧美精品一区 | 亚洲精品久久久久久国产精华液 | 精品三级在线观看 | 美女国产精品 | 91天堂网 | 亚洲一区二区三区免费视频 | 一级毛片视频 | 性生活毛片 | 国产a视频 | 91欧美 | 国产在线一区二区 | 国产成人精品久久二区二区91 | 色综合久久伊人 | 羞羞视频在线观看免费观看 | 91精品国产手机 | 国产成人综合一区二区三区 | 免费在线观看黄视频 | 成人亚洲一区 | 一区欧美| 精精国产xxxx视频在线野外 | 国产9 9在线 | 中文 | 青青久久av北条麻妃海外网 | 999视频在线播放 | 99久热在线精品视频观看 | 亚洲区一区二 | 国产精品国产a级 | 精品亚洲一区二区 | 国产三级大片 | 高清免费av| 亚洲欧美一区二区三区视频 | 久久久激情视频 | 久久久精品影院 | www.久| 日本特黄a级高清免费大片 国产精品久久性 | 久久精品 | 黄网在线观看 | 男女羞羞视频大全 | 最新中文字幕第一页视频 |