1.启动一个Tomcat容器,将Tomcat默认端口8080映射为8888
docker pull tomcat:8.0
docker images tomcat
docker run -d --rm -p 8888:8080 --name lgztomcat tomcat:8.0
192.168.20.19:8888
[root@lgz19docker ~]# vi /root/tomcat-users.xml
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-status"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<user name="admin" password="admin" roles="admin-gui,admin-script,manager-gui,manager-status,manager-script,manager-jmx"/>
</tomcat-users>
[root@lgz19docker ~]# docker cp /root/tomcat-users.xml lgztomcat:/usr/local/tomcat/conf/tomcat-users.xml
[root@lgz19docker ~]# docker exec -it lgztomcat bash
root@9004636f53f0:/usr/local/tomcat# ls
root@9004636f53f0:/usr/local/tomcat# env
root@9004636f53f0:/usr/local/tomcat# cat /usr/local/tomcat/conf/tomcat-users.xml
root@9004636f53f0:/usr/local/tomcat# exit
[root@lgz19docker ~]# docker restart lgztomcat
[root@lgz19docker ~]# docker cp /root/War/hello-world.war lgztomcat:/usr/local/tomcat/webapps
[root@lgz19docker ~]# docker restart lgztomcat
标签:lgztomcat,21,tomcat,local,Tomcat,usr,docker,root,War
From: https://blog.csdn.net/dADDSDWd/article/details/144289369