【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

相关文章
|
13天前
|
关系型数据库 MySQL Docker
docker环境下mysql镜像启动后权限更改问题的解决
在Docker环境下运行MySQL容器时,权限问题是一个常见的困扰。通过正确设置目录和文件的权限,可以确保MySQL容器顺利启动并正常运行。本文提供了多种解决方案,包括在主机上设置正确的权限、使用Dockerfile和Docker Compose进行配置、在容器启动后手动更改权限以及使用 `init`脚本自动更改权限。根据实际情况选择合适的方法,可以有效解决MySQL容器启动后的权限问题。希望本文对您在Docker环境下运行MySQL容器有所帮助。
21 1
|
1月前
|
网络安全 虚拟化 Docker
SSH后判断当前服务器是云主机、物理机、虚拟机、docker环境
结合上述方法,您可以对当前环境进行较为准确的判断。重要的是理解每种环境的特征,并通过系统的响应进行综合分析。如果在Docker容器内,通常会有明显的环境标志和受限的资源视图;而在云主机或虚拟机上,虽然它们也可能是虚拟化的,但通常提供更接近物理机的体验,且可通过硬件标识来识别虚拟化平台。物理机则直接反映硬件真实信息,较少有虚拟化痕迹。通过这些线索,您应该能够定位到您所处的环境类型。
25 2
|
1月前
|
存储 监控 Shell
docker的底层原理二:容器运行时环境
本文深入探讨了Docker容器运行时环境的关键技术,包括命名空间、控制组、联合文件系统、容器运行时以及分离的进程树,这些技术共同确保了容器的隔离性、资源控制和可移植性。
38 5
|
1月前
|
应用服务中间件 Apache Windows
免安装版的Tomcat注册为windows服务
免安装版的Tomcat注册为windows服务
101 3
|
1月前
|
jenkins Java 持续交付
Docker搭建jenkins环境
这篇文章详细介绍了如何利用Docker搭建Jenkins环境,包括拉取Jenkins镜像、配置端口映射及初始化设置的步骤。
127 0
Docker搭建jenkins环境
|
2月前
|
Java 应用服务中间件 Windows
windows服务器重装系统之后,Tomcat服务如何恢复?
windows服务器重装系统之后,Tomcat服务如何恢复?
58 10
|
1月前
|
Linux 持续交付 iOS开发
docker的使用(环境特殊时可以考虑使用)
docker的使用(环境特殊时可以考虑使用)
12 0
|
2月前
|
关系型数据库 数据库 网络虚拟化
Docker环境下重启PostgreSQL数据库服务的全面指南与代码示例
由于时间和空间限制,我将在后续的回答中分别涉及到“Python中采用lasso、SCAD、LARS技术分析棒球运动员薪资的案例集锦”以及“Docker环境下重启PostgreSQL数据库服务的全面指南与代码示例”。如果你有任何一个问题的优先顺序或需要立即回答的,请告知。
68 0
|
2月前
|
关系型数据库 Java MySQL
"解锁Java Web传奇之旅:从JDK1.8到Tomcat,再到MariaDB,一场跨越数据库的冒险安装盛宴,挑战你的技术极限!"
【9月更文挑战第6天】在Linux环境下安装JDK 1.8、Tomcat和MariaDB是搭建Java Web应用的关键步骤。本文详细介绍了使用apt-get安装OpenJDK 1.8、下载并配置Tomcat,以及安装和安全设置MariaDB(MySQL的开源分支)的方法。通过这些步骤,您可以快速构建一个稳定、高效的开发和部署环境,并验证各组件是否正确安装和运行。这为您的Java Web应用提供了一个坚实的基础。
53 0
|
应用服务中间件 Docker 容器
Docker 安装 Tomcat
一、查看 tomcat 版本 访问 tomcat 镜像库地址:https://hub.docker.com/_/tomcat,可以通过 Tags 查看其他版本的 tomcat; 二、拉取 Tomcat Docker 镜像 打开终端或命令提示符,运行以下命令从 Docker Hub 拉取 Tomcat Docker 镜像: docker pull tomcat 三、创建 Tomcat 容器 一旦 Tomcat 镜像下载完成,可以基于该镜像创建一个容器。运行以下命令创建 Tomcat 容器: docker run -d -p 8080:8080 --name tomcat-container t
257 0