Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install nginx and tomcat in Docker

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "how to install nginx and tomcat in Docker". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The previous article showed you how to install and use Docker. In practice today, install tomcat and nginx.

Pull the first docker image

Docker pull hello-world pulls an image

You can configure some domestic mirror sources, which is much faster. Https://hub-mirror.c.163.com https://docker.mirrors.ustc.edu.cn

Docker images View Mirror

Docker run hello-world runs this image

Docker architecture diagram

Pull a nginx

Docker pull nginx uses this command to pull the latest nginx image and run docker run nginx

Docker exec-it xxx goes into the nginx image and executes the command which nginx

The network

Docker run-d-p 9090 nginx 80 nginx background-d runs a nginx and maps the local port 9090 to port 80 of nginx. You can also use docker run-d-P xx to randomly map a port with-P

View the port with lsof-iPart 9090

Pull and start of Tomcat

Tomcat operates in a similar way to nginx.

Then you need to transfer the war package to the running directory of tomcat

Write Dockerfile

FROM tomcat # name of the boot image

MAINTAINER xudong xxd0225@gmail.com # maintenance Information

COPY jpress-v3.3.0.war / usr/local/tomcat/webapps # copy the war package of the current directory to the tocat directory

Start making an imagesdocker build. As many as this name is none, you can use tag to specify a name, note that the name should be all lowercase. Docker build-t chasaystest:1.0.

Then run docker run-d-P 1234Rank 8080 chasaystest. This allows you to map tomcat 8080 to port 1234. The local computer can access the tomcat port with 1234. Http://localhost:1234

That's all for "how Docker installs nginx and tomcat". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report