Art is long, life is long

Docker install Nginx

#1. Search for nginx[root@jiangwang home]# docker search nginx NAME DESCRIPTION STARS nginx Official build of Nginx. 14539 Jwilder/Nginx-proxy Automated Nginx Proxy for Docker Con... 1981 Richarvey /nginx-php-fpm capable of running nginx + php-fpm capable of... 809 JC21 / nginx-proxy-Manager Docker Container for Managing Nginx proxy Ho... 158 LinuxServer/Nginx An Nginx container, brought to you by LinuxS... 142 Tiangolo /nginx-rtmp Docker image with nginx using nginx-rtmp... 115 jlesage/nginx-proxy-manager Docker container for Nginx Proxy Manager 97 bitnami/nginx Bitnami nginx Docker Image 94 Alfg /nginx-rtmp nginx, nginx-rtmp-module and FFmpeg from sou... 89 jasonrivers/nginx-rtmp Docker images to host RTMP streams using NGI... 88 Nginxdemos/Hello NGINX WebServer that serves a simple page co... 67 nginx/nginx-ingress NGINX Ingress Controller for Kubernetes 49 privatebin/nginx-fpm-alpine PrivateBin running on an Nginx, PHP - FPM & Al... 48 nginxinc/nginx-unprivileged Unprivileged NGINX Dockerfiles 31 schmunk42/nginx-redirect A very simple container to Redirect HTTP tra... 19 StaticFloat/nginx-Certbot Opinionated Setup for Automatic TLS Certs LO... Nginx/Prometheus - Exporters nginx Prometheus - exporters centos/nginx-112- Centos7 Platform for running Nginx 1.12 The or building... 15 centos/nginx-18-centos7 Platform for running nginx 1.8 or building n... 12 FlashSPys/NGINX - Static Super Lightweight NGINx Image 9 Bitwarden/Nginx The Bitwarden NGINx Web Server Acting as a... 9 Bitnami /nginx-ingress-controller Bitnami Docker Image for nginx Ingress Contr... 8 mailu/nginx Mailu nginx frontend 8 ansibleplaybookbundle/nginx-apb An APB to deploy NGINX 2 wodby/nginx Generic nginx
#2. Download the nginx image
[root@jiangwang home]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
a076a628af6f: Pull complete 
0732ab25fa22: Pull complete 
d7f36f6fe38f: Pull complete 
f72584a26f32: Pull complete 
7125e4df9063: Pull complete 
Digest: sha256:10b8cc432d56da8b61b070f4c7d2543a9ed17c2b23010b43af434fd40e2ca4aa
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest

#3. Start nginx
#-d Background startup
#--name Specifies the container name
#-p Host port: indicates the container port[root@jiangwang home]# docker run -d --name nginx01 -p 3344:80 nginx 0692aec62ba9f2487653629280becb8bcb915605faee12ee3bd3b8d5de148c32 [root@jiangwang home]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0692aec62ba9 nginx "/ docker-entryPoint...." 7 seconds ago Up 6 seconds 0.0.0.0:3344->80/ TCP nginx01#Try local access[root@jiangwang home]# curl localhost:3344 <! DOCTYPE html> <html> <head> <title>Welcome to nginx! </title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx! </h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html> [root@jiangwang home]#
#Into the container
[root@jiangwang home]# docker exec -it nginx01 /bin/bash
root@0692aec62ba9:/# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
root@0692aec62ba9:/# cd /etc/nginx
root@0692aec62ba9:/etc/nginx# ls
conf.d		koi-utf  mime.types  nginx.conf   uwsgi_params
fastcgi_params	koi-win  modules     scgi_params  win-utf
root@0692aec62ba9:/etc/nginx# 

#Stop the containerroot@0692aec62ba9:/etc/nginx# exit # exit [root@jiangwang home]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0692aec62ba9 nginx "/ docker-entryPoint...." 9 minutes ago Up 9 minutes 0.0.0.0:3344->80/ TCP nginx01 [root@jiangwang home]# docker stop 0692aec62ba9 0692aec62ba9Copy the code

In the browser with public network access, test see, the results can be accessed, which is the premise of your 3344 port number has been developed, as long as the port number can be tested.

Docker install Tomcat

#Downloading the Tomcat Image
[root@jiangwang home]# docker pull tomcat
Using default tag: latest
latest: Pulling from library/tomcat
Digest: sha256:94cc18203335e400dbafcd0633f33c53663b1c1012a13bcad58cced9cd9d1305
Status: Downloaded newer image for tomcat:latest
docker.io/library/tomcat:latest
[root@jiangwang home]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
tomcat       9.0       040bdb29ab37   7 weeks ago    649MB
tomcat       latest    040bdb29ab37   7 weeks ago    649MB
nginx        latest    f6d0b4767a6c   8 weeks ago    133MB
centos       latest    300e315adb2f   3 months ago   209MB
#Start the Tomcat container and map port 8080 of the container to port 3355 of the External network
[root@jiangwang home]# docker run -d -p 3355:8080 --name tomcat01 tomcat
1a0d54668dd61afb333aa0854e1c0ceafca3c8f695f820089d28eefa4977f0f6
[root@jiangwang home]# 
Copy the code

Check in your browser: the result is 404, indicating

#Enter tomcat container, find nothing under webapps, this is the reason of Ali cloud mirror, default is the smallest mirror, all unnecessary are removed, to ensure the smallest runnable environment[root@jiangwang home]# docker exec -it tomcat01 /bin/bash root@1a0d54668dd6:/usr/local/tomcat# ls -al total 176 drwxr-xr-x 1 root root 4096 Jan 13 08:25 . drwxr-xr-x 1 root root 4096 Jan 13 08:19 .. -rw-r--r-- 1 root root 18982 Dec 3 11:48 BUILDING.txt -rw-r--r-- 1 root root 5409 Dec 3 11:48 CONTRIBUTING.md -rw-r--r--  1 root root 57092 Dec 3 11:48 LICENSE -rw-r--r-- 1 root root 2333 Dec 3 11:48 NOTICE -rw-r--r-- 1 root root 3257 Dec 3 11:48 README.md -rw-r--r-- 1 root root 6898 Dec 3 11:48 RELEASE-NOTES -rw-r--r-- 1 root root 16507 Dec 3 11:48 RUNNING.txt drwxr-xr-x 2 root root 4096 Jan 13 08:25 bin drwxr-xr-x 1 root root 4096 Mar 9 11:39 conf drwxr-xr-x 2 root root 4096 Jan 13 08:25 lib drwxrwxrwx 1 root root 4096 Mar 9 11:39 logs drwxr-xr-x 2 root root 4096 Jan 13 08:25 native-jni-lib drwxrwxrwx 2 root root 4096 Jan 13 08:25 temp drwxr-xr-x 2 root root 4096 Jan 13 08:25 webapps drwxr-xr-x  7 root root 4096 Dec 3 11:45 webapps.dist drwxrwxrwx 2 root root 4096 Dec 3 11:43 work root@1a0d54668dd6:/usr/local/tomcat# cd webapps root@1a0d54668dd6:/usr/local/tomcat/webapps# ls root@1a0d54668dd6:/usr/local/tomcat/webapps#

#Copy the files in the webapps. Dist directory to webapps and refresh the page to see the Tomcat page
root@1a0d54668dd6:/usr/local/tomcat/webapps# cd ..
root@1a0d54668dd6:/usr/local/tomcat# cd webapps.dist
root@1a0d54668dd6:/usr/local/tomcat/webapps.dist# ls
ROOT  docs  examples  host-manager  manager
root@1a0d54668dd6:/usr/local/tomcat/webapps.dist# cd ..
root@1a0d54668dd6:/usr/local/tomcat# cp -r webapps.dist/* webapps
root@1a0d54668dd6:/usr/local/tomcat# cd webapps
root@1a0d54668dd6:/usr/local/tomcat/webapps# ls
ROOT  docs  examples  host-manager  manager
root@1a0d54668dd6:/usr/local/tomcat/webapps# 

Copy the code