Docker安装tomcat
# 一般用来测试,用完即删除
docker run -it --rm tomcat:9.0
docker search tomcat
docker pull tomcat
Using default tag: latest
latest: Pulling from library/tomcat
Digest: sha256:a5abf192aceed45620dbb2e09f8abdec2b96108b86365a988c85e753c28cd36b
Status: Downloaded newer image for tomcat:latest
docker.io/library/tomcat:latest
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat 9.0 36ef696ea43d 3 days ago 667MB
tomcat latest 36ef696ea43d 3 days ago 667MB
nginx latest 4f380adfc10f 13 days ago 133MB
docker run -d -p 8080:8080 --name tomcat01 tomcat
227e6d92a9e2eeca7fec3446a1effdb67df6b7647e759e6bb86b891f04ea5f7
- 测试访问没有问题,进入容器,发现Linux命令少了,没有webapps文件。由于阿里云镜像的原因,默认上最小镜像,所有不必要的都剔除了,保证最小运行环境
docker exec -it tomcat01 /bin/bash
root@d227e6d92a9e:/usr/local/tomcat# ls -al
total 172
drwxr-xr-x 1 root root 4096 Jul 2 19:58 .
drwxr-xr-x 1 root root 4096 Jun 26 05:00 ..
-rw-r--r-- 1 root root 18949 Jun 28 08:46 BUILDING.txt
-rw-r--r-- 1 root root 6210 Jun 28 08:46 CONTRIBUTING.md
-rw-r--r-- 1 root root 57092 Jun 28 08:46 LICENSE
-rw-r--r-- 1 root root 2333 Jun 28 08:46 NOTICE
-rw-r--r-- 1 root root 3372 Jun 28 08:46 README.md
-rw-r--r-- 1 root root 6898 Jun 28 08:46 RELEASE-NOTES
-rw-r--r-- 1 root root 16507 Jun 28 08:46 RUNNING.txt
drwxr-xr-x 2 root root 4096 Jul 2 19:58 bin
drwxr-xr-x 1 root root 4096 Jul 6 12:27 conf
drwxr-xr-x 2 root root 4096 Jul 2 19:58 lib
drwxrwxrwx 1 root root 4096 Jul 6 12:27 logs
drwxr-xr-x 2 root root 4096 Jul 2 19:58 native-jni-lib
drwxrwxrwx 2 root root 4096 Jul 2 19:58 temp
drwxr-xr-x 2 root root 4096 Jul 2 19:58 webapps
drwxr-xr-x 7 root root 4096 Jun 28 08:46 webapps.dist
drwxrwxrwx 2 root root 4096 Jun 28 08:46 work
# 可以把tomcat的webapps.dist目录的文件,复制到webapps文件下或者把webapps.dist改名
root@d227e6d92a9e:/usr/local/tomcat# cp -r webapps.dist/* ./webapps
root@d227e6d92a9e:/usr/local/tomcat# root@d227e6d92a9e:/usr/local/tomcat# ls ./webapps
# 查看是否复制成功
root@d227e6d92a9e:/usr/local/tomcat# ls ./webapps
ROOT docs examples host-manager manager
127.0.0.1:8080