Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to install nginx and tomcat in Docker

Shulou Source: shulou.com Published: 2022-06-02 06:29:46 10月05日 Update

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!

Tags: Mirror port run name directory content command actual more knowledge practical successful next information background dilemma lowercase situation article way Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Shulou Technology macOS Docker vpn