【Docker】在Docker环境中安装Tomcat服务

简介: 【Docker】在Docker环境中安装Tomcat服务

一、什么是Tomcat❔


Tomcat是Apache 软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache、Sun 和其他一些公司及个人共同开发而成。因为Tomcat 技术先进、性能稳定,而且免费,因而深受Java 爱好者的喜爱并得到了部分软件开发商的认可,成为比较流行的Web 应用服务器。


二、Docker下安装Tomcat操作演示🎨


1️⃣前期准备


#检查docker是否安装完成。
[root@docker ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.14
 API version:       1.41
 Go version:        go1.16.15
 Git commit:        a224086
 Built:             Thu Mar 24 01:49:57 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Server: Docker Engine - Community
 Engine:
  Version:          20.10.14
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.15
  Git commit:       87a90dc
  Built:            Thu Mar 24 01:48:24 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.5.11
  GitCommit:        3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc:
  Version:          1.0.3
  GitCommit:        v1.0.3-0-gf46b6ba
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
[root@docker ~]#
# 检查docker是否启动
systemctl status docker


2️⃣下载tomcat镜像


# 搜索tomcat镜像
[root@docker ~]# docker search tomcat
NAME                                           DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
tomcat                                         Apache Tomcat is an open source implementati…   3317      [OK]
tomee                                          Apache TomEE is an all-Apache Java EE certif…   96        [OK]
bitnami/tomcat                                 Bitnami Tomcat Docker Image                     44                   [OK]
aallam/tomcat-mysql                            Debian, Oracle JDK, Tomcat & MySQL              12                   [OK]
arm32v7/tomcat                                 Apache Tomcat is an open source implementati…   11
arm64v8/tomcat                                 Apache Tomcat is an open source implementati…   7
rightctrl/tomcat                               CentOS , Oracle Java, tomcat application ssl…   7                    [OK]
maluuba/tomcat7-java8                          Tomcat7 with java8.                             6
amd64/tomcat                                   Apache Tomcat is an open source implementati…   4
tomcat2111/pisignage-server                    PiSignage Server                                3                    [OK]
jelastic/tomcat                                An image of the Tomcat Java application serv…   3
cfje/tomcat-resource                           Tomcat Concourse Resource                       2
oobsri/tomcat8                                 Testing CI Jobs with different names.           2
ppc64le/tomcat                                 Apache Tomcat is an open source implementati…   1
tomcatling/jupyterhub_aws                                                                      1
appsvc/tomcat                                                                                  1
chenyufeng/tomcat-centos                       tomcat基于centos6的镜像                              1                    [OK]
s390x/tomcat                                   Apache Tomcat is an open source implementati…   0
tomcatengineering/pg_backup_rotated            Clone of martianrock/pg_backup_rotated but w…   0
secoresearch/tomcat-varnish                    Tomcat and Varnish 5.0                          0                    [OK]
tomcat2111/papercut-mf                         PaperCut MF Application Server                  0
softwareplant/tomcat                           Tomcat images for jira-cloud testing            0                    [OK]
tomcat2111/phpredisadmin                       This is a Docker image for phpredisadmin        0                    [OK]
tomcat0823/auto1                                                                               0
tomcat2111/bitbucket-pipelines-elasticsearch   Elasticsearch for Bitbucket's Pipelines         0
[root@docker ~]#
# 默认下载官方最新tomcat镜像
[root@docker ~]# docker pull tomcat
Using default tag: latest
latest: Pulling from library/tomcat
0e29546d541c: Pull complete
9b829c73b52b: Pull complete
cb5b7ae36172: Pull complete
6494e4811622: Pull complete
668f6fcc5fa5: Pull complete
dc120c3e0290: Pull complete
8f7c0eebb7b1: Pull complete
77b694f83996: Pull complete
0f611256ec3a: Pull complete
4f25def12f23: Pull complete
Digest: sha256:9dee185c3b161cdfede1f5e35e8b56ebc9de88ed3a79526939701f3537a52324
Status: Downloaded newer image for tomcat:latest
docker.io/library/tomcat:latest
# 查看下载的tomcat镜像
[root@docker ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
tomcat       latest    fb5657adc892   4 months ago   680MB
[root@docker ~]#
# 查看tomcat镜像详细信息
[root@docker ~]# docker inspect fb5657adc892
[
    {
        "Id": "sha256:fb5657adc892ed15910445588404c798b57f741e9921ff3c1f1abe01dbb56906",
        "RepoTags": [
            "tomcat:latest"
        ],
        "RepoDigests": [
            "tomcat@sha256:9dee185c3b161cdfede1f5e35e8b56ebc9de88ed3a79526939701f3537a52324"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2021-12-22T17:07:13.333084424Z",
        "Container": "de0900b3a6caf902ccdaa1c7871d244e29978119ad8a1cce799cf47f1717b679",
        "ContainerConfig": {
            "Hostname": "de0900b3a6ca",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "8080/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/tomcat/bin:/usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "JAVA_HOME=/usr/local/openjdk-11",
                "LANG=C.UTF-8",
                "JAVA_VERSION=11.0.13",
                "CATALINA_HOME=/usr/local/tomcat",
                "TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib",
                "LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib",
                "GPG_KEYS=A9C5DF4D22E99998D9875A5110C01C5A2F6059E7",
                "TOMCAT_MAJOR=10",
                "TOMCAT_VERSION=10.0.14",
                "TOMCAT_SHA512=c2d2ad5ed17f7284e3aac5415774a8ef35434f14dbd9a87bc7230d8bfdbe9aa1258b97a59fa5c4030e4c973e4d93d29d20e40b6254347dbb66fae269ff4a61a5"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "CMD [\"catalina.sh\" \"run\"]"
            ],
            "Image": "sha256:6e2683bf6f13f0050833b6807871b4980142835747139a2c2ae91b274787e399",
            "Volumes": null,
            "WorkingDir": "/usr/local/tomcat",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        },
        "DockerVersion": "20.10.7",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "8080/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/tomcat/bin:/usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "JAVA_HOME=/usr/local/openjdk-11",
                "LANG=C.UTF-8",
                "JAVA_VERSION=11.0.13",
                "CATALINA_HOME=/usr/local/tomcat",
                "TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib",
                "LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib",
                "GPG_KEYS=A9C5DF4D22E99998D9875A5110C01C5A2F6059E7",
                "TOMCAT_MAJOR=10",
                "TOMCAT_VERSION=10.0.14",
                "TOMCAT_SHA512=c2d2ad5ed17f7284e3aac5415774a8ef35434f14dbd9a87bc7230d8bfdbe9aa1258b97a59fa5c4030e4c973e4d93d29d20e40b6254347dbb66fae269ff4a61a5"
            ],
            "Cmd": [
                "catalina.sh",
                "run"
            ],
            "Image": "sha256:6e2683bf6f13f0050833b6807871b4980142835747139a2c2ae91b274787e399",
            "Volumes": null,
            "WorkingDir": "/usr/local/tomcat",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 679618222,
        "VirtualSize": 679618222,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/17750c528974cc2506240a6fc097828a654b5c95254d04351888cc7c37616e8d/diff:/var/lib/docker/overlay2/2baff1b0a90a8a32b6096919dfe7905e80a10644a0e591a235bbf9dfb1ee935f/diff:/var/lib/docker/overlay2/57e4f3246f56478dec6001d04e2a194482af11bbe0cf1fff9bf6b8e80692d80b/diff:/var/lib/docker/overlay2/9c61f3a83975026b30fe67c366749cdc94dce6f8631bdf682b30c241738f5877/diff:/var/lib/docker/overlay2/2cce0104900d2801c26a4fc435b373956d73f7c879f577fe4dee76c5b4e5edf6/diff:/var/lib/docker/overlay2/20e1755fe858a6361dd98e0442356614957f69771bef40fede9ba92fd1f4fe8c/diff:/var/lib/docker/overlay2/6b2303e71edfa4940ad9eb735327bb7dff5a9c1a1f64aab39ad4be0010e8cdc1/diff:/var/lib/docker/overlay2/4fd1c7225ffdf29892025b5bbcffd78c7c30354d645ce060e9dbed6aacd76509/diff:/var/lib/docker/overlay2/7f98cf673a67095f92f9811fa0a1b1433494d4e643bf5ea64c56296d0f64827b/diff",
                "MergedDir": "/var/lib/docker/overlay2/63e3094912356d6fa8ae806060288efe002b8fd505d7c8c13be6b007c23ed74d/merged",
                "UpperDir": "/var/lib/docker/overlay2/63e3094912356d6fa8ae806060288efe002b8fd505d7c8c13be6b007c23ed74d/diff",
                "WorkDir": "/var/lib/docker/overlay2/63e3094912356d6fa8ae806060288efe002b8fd505d7c8c13be6b007c23ed74d/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:11936051f93baf5a4fb090a8fa0999309b8173556f7826598e235e8a82127bce",
                "sha256:31892cc314cb1993ba1b8eb5f3002c4e9f099a9237af0d03d1893c6fcc559aab",
                "sha256:8bf42db0de72f74f4ef0c1d1743f5d54efc3491ee38f4af6d914a6032148b78e",
                "sha256:26a504e63be4c63395f216d70b1b8af52263a5289908df8e96a0e7c840813adc",
                "sha256:f9e18e59a5651609a1503ac17dcfc05856b5bea21e41595828471f02ad56a225",
                "sha256:832e177bb5008934e2f5ed723247c04e1dd220d59a90ce32000b7c22bd9d9b54",
                "sha256:3bb5258f46d2a511ddca2a4ec8f9091d676a116830a7f336815f02c4b34dbb23",
                "sha256:59c516e5b6fafa2e6b63d76492702371ca008ade6e37d931089fe368385041a0",
                "sha256:bd2befca2f7ef51f03b757caab549cc040a36143f3b7e3dab94fb308322f2953",
                "sha256:3e2ed6847c7a081bd90ab8805efcb39a2933a807627eb7a4016728f881430f5f"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]
[root@docker ~]#


3️⃣启动tomcat


# 启动tomcat
[root@docker ~]# docker run -d -p 3366:8080 --name tomcat-xybdiy tomcat
c0b92c78776bdeea0cad131b36e58931e0ffc4b59d08751e8a05a4a3becff92e
###############################
# 参数解释: 
# -p : 宿主机端口:容器内部端口
# -d : 代表后台运行
# --name : 给容器命名
###############################
# 查看容器启动状态信息
[root@docker ~]# docker ps
CONTAINER ID   IMAGE     COMMAND             CREATED         STATUS         PORTS                                       NAMES
c0b92c78776b   tomcat    "catalina.sh run"   2 minutes ago   Up 2 minutes   0.0.0.0:3366->8080/tcp, :::3366->8080/tcp   tomcat-xybdiy
# 查看tomcat容器详细信息
[root@docker ~]# docker inspect tomcat-xybdiy
[
    {
        "Id": "c0b92c78776bdeea0cad131b36e58931e0ffc4b59d08751e8a05a4a3becff92e",
        "Created": "2022-05-06T15:58:32.234116782Z",
        "Path": "catalina.sh",
        "Args": [
            "run"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 12728,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2022-05-06T15:58:32.992454668Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:fb5657adc892ed15910445588404c798b57f741e9921ff3c1f1abe01dbb56906",
        "ResolvConfPath": "/var/lib/docker/containers/c0b92c78776bdeea0cad131b36e58931e0ffc4b59d08751e8a05a4a3becff92e/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/c0b92c78776bdeea0cad131b36e58931e0ffc4b59d08751e8a05a4a3becff92e/hostname",
        "HostsPath": "/var/lib/docker/containers/c0b92c78776bdeea0cad131b36e58931e0ffc4b59d08751e8a05a4a3becff92e/hosts",
        "LogPath": "/var/lib/docker/containers/c0b92c78776bdeea0cad131b36e58931e0ffc4b59d08751e8a05a4a3becff92e/c0b92c78776bdeea0cad131b36e58931e0ffc4b59d08751e8a05a4a3becff92e-json.log",
        "Name": "/tomcat-xybdiy",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {
                "8080/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "3366"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/5fe647bac2e4fbc4c944260bb8c177c05165c53cf170ff4c2cb07b1e589db435-init/diff:/var/lib/docker/overlay2/63e3094912356d6fa8ae806060288efe002b8fd505d7c8c13be6b007c23ed74d/diff:/var/lib/docker/overlay2/17750c528974cc2506240a6fc097828a654b5c95254d04351888cc7c37616e8d/diff:/var/lib/docker/overlay2/2baff1b0a90a8a32b6096919dfe7905e80a10644a0e591a235bbf9dfb1ee935f/diff:/var/lib/docker/overlay2/57e4f3246f56478dec6001d04e2a194482af11bbe0cf1fff9bf6b8e80692d80b/diff:/var/lib/docker/overlay2/9c61f3a83975026b30fe67c366749cdc94dce6f8631bdf682b30c241738f5877/diff:/var/lib/docker/overlay2/2cce0104900d2801c26a4fc435b373956d73f7c879f577fe4dee76c5b4e5edf6/diff:/var/lib/docker/overlay2/20e1755fe858a6361dd98e0442356614957f69771bef40fede9ba92fd1f4fe8c/diff:/var/lib/docker/overlay2/6b2303e71edfa4940ad9eb735327bb7dff5a9c1a1f64aab39ad4be0010e8cdc1/diff:/var/lib/docker/overlay2/4fd1c7225ffdf29892025b5bbcffd78c7c30354d645ce060e9dbed6aacd76509/diff:/var/lib/docker/overlay2/7f98cf673a67095f92f9811fa0a1b1433494d4e643bf5ea64c56296d0f64827b/diff",
                "MergedDir": "/var/lib/docker/overlay2/5fe647bac2e4fbc4c944260bb8c177c05165c53cf170ff4c2cb07b1e589db435/merged",
                "UpperDir": "/var/lib/docker/overlay2/5fe647bac2e4fbc4c944260bb8c177c05165c53cf170ff4c2cb07b1e589db435/diff",
                "WorkDir": "/var/lib/docker/overlay2/5fe647bac2e4fbc4c944260bb8c177c05165c53cf170ff4c2cb07b1e589db435/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "c0b92c78776b",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "8080/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/tomcat/bin:/usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "JAVA_HOME=/usr/local/openjdk-11",
                "LANG=C.UTF-8",
                "JAVA_VERSION=11.0.13",
                "CATALINA_HOME=/usr/local/tomcat",
                "TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib",
                "LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib",
                "GPG_KEYS=A9C5DF4D22E99998D9875A5110C01C5A2F6059E7",
                "TOMCAT_MAJOR=10",
                "TOMCAT_VERSION=10.0.14",
                "TOMCAT_SHA512=c2d2ad5ed17f7284e3aac5415774a8ef35434f14dbd9a87bc7230d8bfdbe9aa1258b97a59fa5c4030e4c973e4d93d29d20e40b6254347dbb66fae269ff4a61a5"
            ],
            "Cmd": [
                "catalina.sh",
                "run"
            ],
            "Image": "tomcat",
            "Volumes": null,
            "WorkingDir": "/usr/local/tomcat",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "10cf9b877928ac69f7252b07f62bdff05bc91c4d292ce08c127b9db0f2416dbe",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "8080/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "3366"
                    },
                    {
                        "HostIp": "::",
                        "HostPort": "3366"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/10cf9b877928",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "c870fe581d49fb5a1ed0ace2730c5338288a5ce805593fed578d9f384b48c93f",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "f92a9c592ee698e109ae6368be86f863f91d3ac013655a88b0c194549dd8e0fb",
                    "EndpointID": "c870fe581d49fb5a1ed0ace2730c5338288a5ce805593fed578d9f384b48c93f",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]
[root@docker ~]#


4️⃣测试访问报错


# 测试访问
# 打开浏览器输入:IP地址:映射端口。本例为http://192.168.200.66:3366/
# 发生"HTTP状态404"报错信息,表示服务器未得到请求,没有找到请求资源。



5️⃣修改配置参数


# 查看Tomcat容器
docker ps
# 进入Tomcat容器
[root@docker ~]# docker exec -it tomcat-xybdiy /bin/bash
# 查看文件
root@c0b92c78776b:/usr/local/tomcat# ls
BUILDING.txt  CONTRIBUTING.md  LICENSE  NOTICE  README.md  RELEASE-NOTES  RUNNING.txt  bin  conf  lib  logs  native-jni-lib  temp  webapps  webapps.dist  work
# 查看webapps目录
root@c0b92c78776b:/usr/local/tomcat# ls -l webapps
total 0
# 查看webapps.dist目录
root@c0b92c78776b:/usr/local/tomcat# ls -l webapps.dist/
total 4
drwxr-xr-x  3 root root  223 Dec 22 17:06 ROOT
drwxr-xr-x 15 root root 4096 Dec 22 17:06 docs
drwxr-xr-x  7 root root   99 Dec 22 17:06 examples
drwxr-xr-x  6 root root   79 Dec 22 17:06 host-manager
drwxr-xr-x  6 root root  114 Dec 22 17:06 manager
# 拷贝 webapps.dist目录下的文件到webapps目录下
root@c0b92c78776b:/usr/local/tomcat# cp -r webapps.dist/* webapps/
# 查看webapps目录
root@c0b92c78776b:/usr/local/tomcat# ls -l webapps
total 4
drwxr-xr-x  3 root root  223 May  6 16:08 ROOT
drwxr-xr-x 15 root root 4096 May  6 16:08 docs
drwxr-xr-x  7 root root   99 May  6 16:08 examples
drwxr-xr-x  6 root root   79 May  6 16:08 host-manager
drwxr-xr-x  6 root root  114 May  6 16:08 manager
root@c0b92c78776b:/usr/local/tomcat#
# 退出容器
root@c0b92c78776b:/usr/local/tomcat# exit
exit


6️⃣重新测试访问


测试访问成功。



三、参考链接🔗


Apache Tomcat® - Welcome!


Tomcat - Official Image | Docker Hub

相关文章
|
15天前
|
Linux 虚拟化 Docker
Windows10安装Docker Desktop(大妈看了都会)
Windows10安装Docker Desktop(大妈看了都会)
321 2
|
8天前
|
消息中间件 PHP 数据安全/隐私保护
docker安装rabbitmq并配置hyperf使用
通过以上步骤,您可以实现在Docker容器中安装和配置RabbitMQ,并在PHP的Hyperf框架中进行集成和使用。这种方式为开发者提供了快速部署并实现消息队列解决方案的能力,同时维持了环境与生产环境的一致性,从而为开发高效的分布式应用程序提供了便利。
14 3
docker安装rabbitmq并配置hyperf使用
|
7天前
|
网络安全 文件存储 C#
Docker 安装迅雷NAS
【7月更文挑战第3天】在Docker中安装迅雷NAS的步骤包括:确保已安装Docker,使用`docker run`命令拉取镜像(可选阿里云仓库),设置容器参数如命名、主机名、网络模式、挂载目录和重启策略,并开启防火墙端口。访问迅雷NAS网页需内测邀请码,注意安全性和内网使用。操作可能因设备和网络环境差异需调整。
56 15
|
5天前
|
关系型数据库 MySQL Linux
Docker安装mysql详细教程, mysqld: Can‘t read dir of ‘/etc/mysql/conf.d/‘(报错已解决)
Docker安装mysql详细教程, mysqld: Can't read dir of '/etc/mysql/conf.d/' (Errcode: 2 - No such file or directory) 已解决
|
12天前
|
存储 Linux 网络安全
Centos安装Docker的详细安装步骤,Docker相关组件:docker-ce-cli、docker-ce和containerd.io的区别
Centos安装Docker的详细安装步骤,Docker相关组件:docker-ce-cli、docker-ce和containerd.io的区别;CentOS7安装DockerCompose;Docker镜像仓库
254 11
|
10天前
|
Docker 容器
docker安装minio
以上就是在Docker中安装MinIO的步骤。
15 2
|
10天前
|
Docker 容器
docker desktop安装es并连接elasticsearch-head:5
以上就是在Docker Desktop上安装Elasticsearch并连接Elasticsearch-head:5的步骤。
30 2
|
12天前
|
监控 数据可视化 Linux
使用Portainer图形化工具轻松管理远程Docker环境并实现远程访问
使用Portainer图形化工具轻松管理远程Docker环境并实现远程访问
|
12天前
|
应用服务中间件 API 数据库
Docker 安装 KONG 带你玩转 API 网关
**摘要:** 在微服务架构中,API网关Kong作为流行开源选择,提供身份验证、安全和流量控制等功能。通过Docker部署Kong简单高效。步骤包括:创建Docker网络,部署PostgreSQL数据库,初始化Kong数据库,启动Kong容器,并检查运行状态。此外,安装Konga管理界面便于直观管理Kong。使用Docker命令行,逐步设置环境变量和网络连接,即可完成安装。当不再需要时,可清理相关容器和网络。Kong结合Konga,为API管理提供强大且用户友好的解决方案。
25 1
|
18天前
|
XML Java 应用服务中间件
Tomcat服务器的简介以及安装
Tomcat服务器的简介以及安装
33 3