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 for Docker

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "Docker how to install Nginx", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Docker how to install Nginx" bar!

Docker install Nginx

# 1. Search image search. It is recommended that everyone go to docker to search, and you can see the help documentation information.

# 2. Download image pull

# 3. Run the test

[root@dockertest home] # docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

Nginx latest ae2feff98a0c 3 weeks ago 133MB

Centos latest 300e315adb2f 5 weeks ago 209MB

#-d backend

#-name names the container

#-p Host port: container internal port

[root@dockertest home] # docker run-d-- name nginx01-p 3344Mun80 nginx

35578ede3b7c1d0f849fe1f1ecad9419e8577eb9fcbed215c3d2bcdc5ab41f45

[root@dockertest home] # docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

35578ede3b7c nginx "/ docker-entrypoint." 15 seconds ago Up 15 seconds 0.0.0.0 80/tcp nginx01 3344->

[root@dockertest home] # curl localhost:3344

Welcome to nginx!

Body {

Width: 35em

Margin: 0 auto

Font-family: Tahoma, Verdana, Arial, sans-serif

}

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and

Working. Further configuration is required.

For online documentation and support please refer to

Nginx.org.

Commercial support is available at

Nginx.com.

Thank you for using nginx.

# enter the container

[root@dockertest home] # docker exec-it nginx01 / bin/bash

Root@35578ede3b7c:/# whereis nginx

Nginx: / usr/sbin/nginx / usr/lib/nginx / etc/nginx / usr/share/nginx

Root@35578ede3b7c:/# cd / etc/nginx

Root@35578ede3b7c:/etc/nginx# ls

Conf.d fastcgi_params koi-utf koi-win mime.types modules nginx.conf scgi_params uwsgi_params win-utf

Root@35578ede3b7c:/etc/nginx#

Root@35578ede3b7c:/etc/nginx#

Question to consider: every time we change the nginx configuration file, we need to go inside the container. It's very troublesome. If you want to provide a mapping path outside the container, you can modify the file outside the container and automatically inside the container. -v data volume! Can be realized.

Assignment: docker to install a tomcat

# official use

Docker run-it-- rm tomcat:9.0

# all our previous launches are in the background. After stopping the container, the container can still find docker run-it-- rm, which is usually used for testing, indicating deletion after use.

# download and then start

Docker pull tomcat

# start and run

Docker run-d-p 3355 8080-- name tomcat01 tomcat

# there is no problem with test access (404 returned)

# enter the container

[root@dockertest home] # docker exec-it tomcat01 / bin/bash

# found problems: 1. Fewer linux commands. 2. No webapps. Reason: Aliyun image is the smallest image by default, and all unnecessary images are removed.

# ensure a minimum runnable environment!

Question to consider: we have to deploy the project in the future. Is it very troublesome to enter the container every time? If only I could provide a mapping path outside the container, webapps, we would automatically synchronize to the inside if we put the project on the outside!

Job: deploy es + kibana

# es exposes a lot of ports!

# es consumes very much memory

# es data generally needs to be placed in a secure directory! Mounting

#-net somenetwork? Network configuration

# start

Docker run-d-- name elasticsearch-p 9200 discovery.type=single-node 9200-p 9300 discovery.type=single-node 9300

# after startup, linux jammed docker stats to check the status of cpu

# es consumes a lot of memory and takes up 1. 1? G.

# View docker stats

# Test whether es is successful or not

# close and increase the memory limit

# close, increase the memory limit, modify the configuration file-e environment configuration modification (- Xms64-Xmx512 represents a minimum memory of 64m, a maximum memory of 512m)

Docker run-d-name elasticsearch02-p 9200 ES_JAVA_OPTS= 9200-p 9300 ES_JAVA_OPTS= 9300-e "discovery.type=single-node"-Xms64m-Xmx512m "elasticsearch:7.6.2

[root@dockertest home] #

[root@dockertest home] # curl localhost:9200

{

"name": "45248b17305f"

"cluster_name": "docker-cluster"

"cluster_uuid": "lEBi4LDuRHOlF8FlEk_7Fg"

"version": {

"number": "7.6.2"

"build_flavor": "default"

"build_type": "docker"

"build_hash": "ef48eb35cf30adf4db14086e8aabd07ef6fb113f"

"build_date": "2020-03-26T06:34:37.794943Z"

"build_snapshot": false

"lucene_version": "8.4.0"

"minimum_wire_compatibility_version": "6.8.0"

"minimum_index_compatibility_version": "6.0.0-beta1"

}

"tagline": "You Know, for Search"

}

Thank you for reading, the above is the content of "how to install Nginx in Docker". After the study of this article, I believe you have a deeper understanding of how to install Nginx in Docker, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Servers

Wechat

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

12
Report