1. 程式人生 > >Nginx從安裝到執行以及如何訪問(詳解)

Nginx從安裝到執行以及如何訪問(詳解)

使用 docker 拉取映象和建立容器-nginx
本文主要分享通過從docker hub上獲取nginx映象
1、首先查詢nginx映象
[[email protected] ~]# docker search nginx
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
nginx Official build of Nginx. 8238 [OK]
jwilder/nginx-proxy Automated Nginx reverse proxy for docker con… 1301 [OK]
richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable of… 538 [OK]
jrcs/letsencrypt-nginx-proxy-companion LetsEncrypt container to use with nginx as p… 335 [OK]
kong Open-source Microservice & API Management la… 170 [OK]
webdevops/php-nginx Nginx with PHP-FPM 97 [OK]
kitematic/hello-world-nginx A light-weight nginx container that demonstr… 95
zabbix/zabbix-web-nginx-mysql Zabbix frontend based on Nginx web-server wi… 48 [OK]
bitnami/nginx Bitnami nginx Docker Image 45 [OK]
linuxserver/nginx An Nginx container, brought to you by LinuxS… 33
1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 30 [OK]
tobi312/rpi-nginx NGINX on Raspberry Pi / armhf 19 [OK]
wodby/drupal-nginx Nginx for Drupal container image 9 [OK]
nginxdemos/nginx-ingress NGINX Ingress Controller for Kubernetes 8
blacklabelops/nginx Dockerized Nginx Reverse Proxy Server. 8 [OK]
webdevops/nginx Nginx container 8 [OK]
centos/nginx-18-centos7 Platform for running nginx 1.8 or building n… 6
1science/nginx Nginx Docker images that include Consul Temp… 4 [OK]
nginxdemos/hello NGINX webserver that serves a simple page co… 4 [OK]
centos/nginx-112-centos7 Platform for running nginx 1.12 or building … 3
pebbletech/nginx-proxy nginx-proxy sets up a container running ngin… 2 [OK]
behance/docker-nginx Provides base OS, patches and stable nginx f… 2 [OK]
toccoag/openshift-nginx Nginx reverse proxy for Nice running on same… 1 [OK]
travix/nginx NGinx reverse proxy 1 [OK]
mailu/nginx Mailu nginx frontend 0 [OK]
2、拉取官網的nginx映象
[

[email protected] ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
2a72cbf407d6: Pull complete
fefa2faca81f: Pull complete
080aeede8114: Pull complete
Digest: sha256:c4ee0ecb376636258447e1d8effb56c09c75fe7acf756bf7c13efadf38aa0aca
Status: Downloaded newer image for nginx:latest
3、檢視獲取到的映象檔案
[
[email protected]
~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 7f70b30f2cc6 7 days ago 109MB
ubuntu 14.04 a35e70164dfb 3 weeks ago 222MB
ubuntu 17.10 1af812152d85 3 weeks ago 98.4MB
4、啟動nginx 容器,對映埠
[[email protected] ~]# docker run -d -p 80:80 nginx
759d6d37858bcc70867321759df12d2881e6399204f2ba6a4b8b10aaea430da3
啟動後nginx驗證
訪問虛機ip例如192.168.9.41我虛機的ip與對映的埠
在這裡插入圖片描述

nginx並不執行專案的載體,nginx配置了負載均衡以後可以緩解伺服器的請求壓力。