在docker centos内启动tomcat服务器时出错

在docker centos内启动tomcat服务器时出错,tomcat,docker,centos,docker-compose,Tomcat,Docker,Centos,Docker Compose,我正在尝试启动一个apache服务器,它运行在centos中的docker容器中。在Dockerfile中,要运行服务器,我有以下命令: FROM centos:6 #(few commands) CMD sleep 60 && sh /opt/liferay/liferay/tomcat-6.0.32/bin/startup.sh && tail -f /opt/liferay/liferay/tomcat-6.0.32/logs/catalina.out

我正在尝试启动一个apache服务器,它运行在centos中的docker容器中。在Dockerfile中,要运行服务器,我有以下命令:

FROM centos:6
#(few commands)
CMD sleep 60 && sh /opt/liferay/liferay/tomcat-6.0.32/bin/startup.sh  && tail -f /opt/liferay/liferay/tomcat-6.0.32/logs/catalina.out
但我在为apache运行startup.sh时遇到以下错误

: command not founday/liferay/tomcat-6.0.32/bin/startup.sh: line 2:
: command not founday/liferay/tomcat-6.0.32/bin/startup.sh: line 17:
: command not founday/liferay/tomcat-6.0.32/bin/startup.sh: line 23:
'eb_1  | /opt/liferay/liferay/tomcat-6.0.32/bin/startup.sh: line 27: syntax error near unexpected token `in
'eb_1  | /opt/liferay/liferay/tomcat-6.0.32/bin/startup.sh: line 27: `case "`uname`" in
下面是我的startup.sh的前30行

#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# -----------------------------------------------------------------------------
# Start Script for the CATALINA Server
#
# $Id: startup.sh 562770 2007-08-04 22:13:58Z markt $
# -----------------------------------------------------------------------------

# Better OS/400 detection: see Bugzilla 31132
os400=false
darwin=false
case "`uname`" in
CYGWIN*) cygwin=true;;
OS400*) os400=true;;
Darwin*) darwin=true;;

查看第2行、第17行、第23行等出现错误的行号。。。。 似乎它们都发生在有新线路的时候

检查startup.sh文件设置,它应该是LF而不是CRLF。我确实和LF检查了脚本,它正在centOS 6上运行


如果您使用windows构建docker容器,您可以查看更多信息。

是。这是某种行尾字符错误。通过在所有shell脚本上运行dos2unix解决了此问题。谢谢