[英]unable to add server.xml on tomcat8 dockerfile. error in xml
Ok I´m quite lost over here and tried many things unable to solve problem. 好的,我在这里迷失了方向,尝试了许多无法解决问题的方法。 this is the situation.
这种情况。 I´m building a tomcat 8 official image with a dockerfile.
我正在使用dockerfile构建tomcat 8官方映像。 the thing is under this image te server.xml file points to port 8080 and I would like to point to port 443. So I enter the container.
问题是在此映像下,server.xml文件指向端口8080,而我想指向端口443。因此,我进入了容器。 cat the /conf/server.xml file, copy the content to a local editor (sublime, notepad ++ or visual studio code) change the part 8080 by 443 and also added certificates like this.
处理/conf/server.xml文件,将内容复制到本地编辑器(sublime,notepad ++或Visual Studio代码),将8080部分更改为443,并添加这样的证书。 the rest of the xml files remains the same
其余的xml文件保持不变
<Connector port="443" protocol="HTTP/1.1"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false"
SSLCertificateFile="conf/star.grey.com.crt"
SSLCertificateKeyFile="conf/server.key"
SSLVerifyClient="optional"
SSLProtocol="TLSv1.2"/>
Then I saved the file localy on my editor as server.xml and add this file on same destination of dockerfile in which I add the line: ADD server.xml /conf/server.xml (which overwrites the existing one) 然后,我在编辑器中将文件的本地设置保存为server.xml,并将此文件添加到与dockerfile相同的目标位置,并在其中添加以下行:ADD server.xml /conf/server.xml(覆盖现有文件)
So I have 2 new images alpine:tomcat8 and alpine:tomcat8-with-new-serverxml 所以我有2张新图片alpine:tomcat8和alpine:tomcat8-with-new-serverxml
I if run a container with the oficial image without any modification, it runs successfully. 如果运行带有官方映像的容器而不进行任何修改,则它将成功运行。 If i Run a container with the modified image i get now:
如果我使用修改后的图像运行容器,我会得到:
-Aug-2018 14:28:56.303 SEVERE [main] org.apache.tomcat.util.digester.Digester.fatalError Parse Fatal Error at line 1 column 1: Content is not allowed in prolog.
org.xml.sax.SAXParseException; systemId: file:/usr/local/tomcat/conf/server.xml; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
Is the same exact xml that I copied from container from /conf/server.xml. 与从/conf/server.xml从容器复制的xml完全相同。 I just modified 443 port and added the certificates.
我刚刚修改了443端口并添加了证书。
how come same file now is unrecognized? 为什么现在无法识别同一文件? I tried:
我试过了:
copyng the container content of server.xml in a new file locally, modified the 443 part. 将server.xml的容器内容复制到本地的新文件中,修改了443部分。 save as server.xml with utf-8 ANSI, utf-8 or NO BOM in notepadd ++ , sublime or visual stuio code.
使用utf-8 ANSI,utf-8或NO BOM以notepadd ++,sublime或visual stuio代码另存为server.xml。 And every time I upload the file to the image and container starts I get same issue.
每次我将文件上传到图像和容器时,都会遇到相同的问题。 How can I solve this?
我该如何解决? it´s driving me crazy.
这让我疯狂。
I tried the option of entering the container modifying the file and commitin change to new image and this works, but this doesn´t help, since this image is build during a pipeline with jenkins, i can´t login in container during the jenkins pipeline. 我尝试了进入修改文件的容器并提交更改为新映像的选项,此方法可行,但这无济于事,因为此映像是在使用jenkins的管道中构建的,因此我无法在jenkins管道中登录容器。
PLEASE HELP 请帮忙
thank you 谢谢
this is what is original on server.xml 这是server.xml上的原始内容
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
this is what I would like to chang it for: 这就是我要更改的内容:
<Connector port="443" protocol="HTTP/1.1"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false"
SSLCertificateFile="conf/star.grey.com.crt"
SSLCertificateKeyFile="conf/server.key"
SSLVerifyClient="optional"
SSLProtocol="TLSv1.2" />
Also I use the cat -A in server.xml on docker container that is working ok and file saw some "$" characters in some parts. 另外,我在docker容器上的server.xml中使用cat -A正常工作,并且文件在某些部分看到了一些“ $”字符。 Should I remove them manually?
我应该手动删除它们吗? However why If copied from original and they already have those "$" when I edit that file and add it again it give the error that I´m getting?
但是,为什么在我编辑该文件并再次添加该文件时,如果从原始副本复制并且它们已经具有那些“ $”,却出现我得到的错误? quite conffuging .
相当混乱。 check image of some part of the original web.xml in container that is running.
检查正在运行的容器中原始web.xml的某些部分的图像。
Can you open a shell in your new created container and try to cat the server.xml file? 您可以在新创建的容器中打开外壳,然后尝试放置server.xml文件吗? Use
cat -A
to show all the hidden characters. 使用
cat -A
显示所有隐藏的字符。
That error is caused probably by a non-existent file or a character before the beginning of the xml content. 该错误可能是由于xml内容开头之前的文件不存在或字符引起的。
Also, if the only thing you're doing is changing the tomcat's port you have other solutions: 另外,如果您唯一要做的就是更改tomcat的端口,那么您还有其他解决方案:
-p 443:8080
-p 443:8080
-v ./server.xml:/conf/server.xml
-v ./server.xml:/conf/server.xml
运行时,使用配置挂载server.xml。 RUN value=
cat conf/server.xml && echo "${value//8080/443}" >| conf/server.xml
RUN value=
cat conf / server.xml && echo "${value//8080/443}" >| conf/server.xml
&& echo "${value//8080/443}" >| conf/server.xml
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.