更新:清理并直接指出问题和解决方案。
问题:
已正确安装和运行Docker-tomcat,但在管理器应用程序中遇到403访问错误。同时,我的Docker Tomcat似乎无法找到我的tomcat-users.xml配置文件。
解决方案:
[文件]:
Dockerfile
FROM tomcat:8.5.11
MAINTAINER Borgy Manotoy <borgymanotoy@ujeaze.com>
# Update Apt and then install Nano editor (RUN can be removed)
RUN apt-get update && apt-get install -y \
nano \
&& mkdir -p /usr/local/tomcat/conf
# Copy configurations (Tomcat users, Manager app)
COPY tomcat-users.xml /usr/local/tomcat/conf/
COPY context.xml /usr/local/tomcat/webapps/manager/META-INF/
Tomcat用户配置(conf/tomcat-users.xml)
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="admin" password="password" roles="manager-gui,manager-script" />
</tomcat-users>
应用程序上下文(webapps/manager/META-INF/context.xml)
<?xml version="1.0" encoding="UTF-8"?>
<Context antiResourceLocking="false" privileged="true" >
<!--
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
</Context>
[步骤和命令]:
构建 Docker 镜像
docker build -t borgymanotoy/my-tomcat-docker .
运行镜像 (my-tomcat-docker 并将端口设置为 8088)
docker run --name my-tomcat-docker-container -p 8088:8080 -it -d borgymanotoy/my-tomcat-docker
进入容器的 bash (通过 bash 检查容器内的文件)
docker exec -it biyahe-tomcat-docker-container bash