我正在尝试在 docker 容器内启动一个在 centos 中运行的 apache 服务器。在我的 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 上工作。
你可以看看Running Scripts in a Docker Container from Windows- CR or CRLF如果您使用 Windows 来构建 docker 容器,请获取更多信息。
关于tomcat - 在 docker centos 中启动 tomcat 服务器时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42761316/