Docker deployment nginx, tomcat

Docker deployment nginx
insert image description here

Pull nginx and display

[root@localhost ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
a2abf6c4d29d: Pull complete 
a9edb18cadd1: Pull complete 
589b7251471a: Pull complete 
186b1aaa4aa6: Pull complete 
b4df32aa5a72: Pull complete 
a0bcbecc962e: Pull complete 
Digest: sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
[root@localhost ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
nginx         latest    605c77e624dd   6 months ago   141MB
hello-world   latest    feb5d9fea6a5   9 months ago   13.3kB
centos        latest    5d0da3dc9764   9 months ago   231MB

Exposed port startup:
the local machine is 3344, which maps to 80 in docker

[root@localhost ~]# docker run -d --name nginx01 -p 3344:80 nginx

test:

 curl localhost:3344

The following figure is displayed to indicate that the access is successful:
insert image description here
Port exposure Explanation:
insert image description here
Deploy tomcat
to pull tomcat
official:
insert image description here

docker pull tomcat:9.0

Run and test:

[root@localhost ~]# docker run -d -p 3355:8080 --name tomcat01 tomcat  #默认是最新,所以需要指定版本号
Unable to find image 'tomcat:latest' locally
 ^C
[root@localhost ~]# docker run -d -p 3355:8080 --name tomcat01 tomcat:9.0
07d324d85900e7bd14d82f3d0ce9330ab45f44971eced296e5bc2d7df7f795c7
[root@localhost ~]# curl localhost:3355
<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {
    
    font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {
    
    color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/9.0.56</h3></body></html>[root@localhost ~]# 

It was found that it was 404, indicating that it was not completely successful.
Found the problem:
insert image description here
You can see that there is no ll command in this container, and there is nothing under the webapps directory. It shows that this container only has the most basic guarantee, and some content does not exist.
Solve the problem:
We copy the content under webapps.dist to webapps, and the operation is as follows.
insert image description here
Tested again and it worked.
insert image description here

Guess you like

Origin blog.csdn.net/aaatomaaa/article/details/125634762
Recommended