2016-08-12 42 views
1

我試圖創造出設置自定義的Tomcat端口(我知道你可以設置一個外部端口與泊塢窗標誌「-p 8888:8080」泊塢窗的圖像,但我用例我想更改內部端口)。高山的Linux在泊塢窗容器忽略shell腳本參數

當我嘗試啓動catalina.sh運行參數被忽略的某些原因。

Dockerfile:

# 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,是相同的,除了使用該線的默認:

<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 

圖像成功建立,但是當我

運行
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 

我很確定我在這裏錯過了一些簡單的東西。我猜想它與語法有關,但也許它與docker或alpine有關,我不知道。這是我第一次使用高山linux。

---編輯1 ---

解釋一下我的使用情況?因爲它是由一個Apache mesos任務設置創建泊塢窗圖像後,我設置端口。爲了我的目的,我需要在主機模式下運行碼頭容器(從馬拉松),而不是橋接模式。

---編輯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運行」失敗,無效的選項,從Windows系統中的換行首先檢查。當在Linux環境中讀取shell腳本時,它們會導致錯誤。


看着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編輯文件。這解決了它。除非你想作出另一個答案,否則我可以將其標記爲正確答案。 –