2016-08-12 2 views
1

私はカスタムTomcatポートを設定するドッカー画像を作成しようとしています(私はドッカーフラグ "-p 8888:8080"私は内部ポートも変更したい)。シェルスクリプトの引数を無視して、ドッカーコンテナ内のアルパインlinux

catalina.shを起動しようとすると、何らかの理由でrun引数が無視されています。

Dockerfile:

<Connector port="${port.http.nonssl}" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> 

start-tomcat.sh:

#!/bin/sh 
export JAVA_OPTS=-Dport.http.nonssl=${PORT} 
catalina.sh run 

# Tomcat 8 alpine dockerfile copied here (URL below)... minus the CMD line at the end 
# https://github.com/docker-library/tomcat/blob/5f1abae99c0b1ebbd4f020bc4b5696619d948cfd/8.0/jre8-alpine/Dockerfile 

ADD server.xml $CATALINA_HOME/conf/server.xml 
ADD start-tomcat.sh /start-tomcat.sh 
RUN chmod +x /start-tomcat.sh 
ENTRYPOINT ["/bin/sh","/start-tomcat.sh"] 

Tomcatのファイル、server.xmlには、ラインを除いて、デフォルトと同じです

イメージは正常に作成されますが、実行時に

docker run -p 8888:8888 -e PORT=8888 customtomcat 

catalina.shコマンドのリストは、あたかも引数を与えなかったかのように表示されます。私も試しました

/usr/local/tomcat/bin/catalina.sh run 

sh -c "catalina.sh run" 

sh -c "/usr/local/tomcat/bin/catalina.sh run" 

cd /usr/local/tomcat/bin 
./catalina.sh run 

私はここに簡単なものがないと確信しています。私はそれが文法と関係があると思うだろうが、多分それは私が知らないドッカーやアルパインと関係があるかもしれない。これは私の初めてのアルパインlinuxを使用しています。それはapacheのmesosタスクによって設定されているためドッキングウィンドウのイメージが作成された後

---編集1 ---

私のユースケースを説明するために...私はPORTを設定しています。私の目的のためには、ブリッジモードではなくホストモードでドッカーコンテナ(マラソンから)を実行する必要があります。

---編集2 ---

私の主な問題のみに焦点を当てるように修正されました。

ADD start-tomcat.sh /start-tomcat.sh 
RUN chmod +x /start-tomcat.sh 
ENTRYPOINT ["/bin/sh","/start-tomcat.sh"] 

そしてstart-tomcat.sh:

#!/bin/bash 
catalina.sh run 

まだ運ドッカファイルは現在、唯一の次は、最後に追加しました。

答えて

2

更新: "catalina.sh run"が無効なオプションで失敗する場合は、まずWindowsシステムから改行を確認してください。 Linux環境でシェルスクリプトを読み込むとエラーが発生します。


catalina.shを見て、私はあなたがCATALINA_OPTS、ないJAVA_OPTSをしたいと考えている:

# Control Script for the CATALINA Server 
# 
# Environment Variable Prerequisites 
# 
# Do not set the variables in this script. Instead put them into a script 
# setenv.sh in CATALINA_BASE/bin to keep your customizations separate. 
# 
# CATALINA_HOME May point at your Catalina "build" directory. 
# 
# CATALINA_BASE (Optional) Base directory for resolving dynamic portions 
#     of a Catalina installation. If not present, resolves to 
#     the same directory that CATALINA_HOME points to. 
# 
# CATALINA_OUT (Optional) Full path to a file where stdout and stderr 
#     will be redirected. 
#     Default is $CATALINA_BASE/logs/catalina.out 
# 
# CATALINA_OPTS (Optional) Java runtime options used when the "start", 
#     "run" or "debug" command is executed. 
#     Include here and not in JAVA_OPTS all options, that should 
#     only be used by Tomcat itself, not by the stop process, 
#     the version command etc. 
#     Examples are heap size, GC logging, JMX ports etc. 
# 
# CATALINA_TMPDIR (Optional) Directory path location of temporary directory 
#     the JVM should use (java.io.tmpdir). Defaults to 
#     $CATALINA_BASE/temp. 
# 
# JAVA_HOME  Must point at your Java Development Kit installation. 
#     Required to run the with the "debug" argument. 
# 
# JRE_HOME  Must point at your Java Runtime installation. 
#     Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME 
#     are both set, JRE_HOME is used. 
# 
# JAVA_OPTS  (Optional) Java runtime options used when any command 
#     is executed. 
#     Include here and not in CATALINA_OPTS all options, that 
#     should be used by Tomcat and also by the stop process, 
#     the version command etc. 
#     Most options should go into CATALINA_OPTS. 
+0

それはラインの下に何かを修正する方法を私は見ることができますが、私は「ドン際に問題がまださえ存在しますOPTSを全く設定しないでください(編集2参照)。 –

+0

Windowsマシンでstart-tomcat.shを変更していますか?最初の推測はファイル内のウィンドウ改行です。それを超えると、Dockerfileで使用している 'FROM'行を見て、使用しているcatalina.shのバージョンを絞り込んだり、変更した場合はこのファイルをインクルードすることができます。 – BMitch

+0

ファイルの元のバージョンがWindowsで作成されました。私はnanoでファイルを編集していたので、私はそれを完全に忘れてしまった。それはそれを修正した。あなたが別の答えをしたいのでなければ、これを正解とすることができます。 –

関連する問題