The Docker practice

Use Docker to deploy Nginx

start

#The first step is to search the Docker Hub
[root@VM-0-11-centos /]# docker search nginx

#Step 2 Download
[root@VM-0-11-centos /]# docker pull nginx

#Start the 
#The container 80 is used here to rename port 3344 on the host to nginx01
#- the name rename
#-p Host port 
[root@VM-0-11-centos /]# docker run -d --name nginx01 -p 3344:80 nginx 

#To view
#Using curl to verify that you are accessing port 3344 of a host[root@VM-0-11-centos /]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 933ee17088da nginx "/ docker - entrypoint...." 55 seconds ago Up 54 seconds 0.0.0.0:3344->80/ TCP nginx01 [root@VM-0-11-centos /]# 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>Copy the code

#Into the container
[root@VM-0-11-centos /]# docker exec -it nginx01 /bin/bash
root@933ee17088da:/# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx

Copy the code

Think about:

You need to enter the container every time you modify the configuration file

Make changes outside the container and inside the file

-v Data volume technology

Use Docker to install Tomcat

#Official use
$Docker runit --rm tomcat:9.0

#The previous startup belongs to the background after the container can still check using the official command is delete as soon as use

#For your own use, download first and start later
[root@VM-0-11-centos /]# docker pull tomcat

#Start the
[root@VM-0-11-centos /]# docker run -d -p 3355:8080 --name tomcat01 tomcat

#There was no problem with the test access

#Into the container
[root@VM-0-11-centos /]# docker exec -it tomcat01 /bin/bash

#Found problem Linux command missing no files under Webapps default minimum mirror all unnecessary file removal to ensure minimum runnable environment

Copy the code

Deploy ElasticSearch with Docker

#Es exposes many ports
#Es is very memory intensive and data needs to be mounted

#- net somenetwork network
#Start the
$ docker run -d --name elasticsearch --net somenetwork -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node"Elasticsearch: 7.10.1

#Start directly stuck  

#Check the docker stats 

#-e Changes the environment configurationdocker run -d --name elasticsearch01 -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-xms64m - xmx512m elasticsearch: 7.10.1.Copy the code