1. Docker installation and configuration

1 Installation Dependencies

yum install -y yum-utils \device-mapper-persistent-data \lvm2
Copy the code

2 Configure the yum source

Aliyun is recommended in China:

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Copy the code

3 Installation Version

View the Docker version list

yum list docker-ce --showduplicates | sort -r
Copy the code

Install the appropriate version

#yum install -y containerd. IO yum install -y containerd-ce -20.10.3-3.el7 Docker - ce - cli - 20.10.3-3. El7 containerd. IOCopy the code

4 start the docker

systemctl start docker
Copy the code

5 Configure mirror vault acceleration

vi /etc/docker/daemon.json { "mtu":1450, "registry-mirrors": [# domestic mirror warehouse "http://hub-mirror.c.163.com", "https://1nj0zren.mirror.aliyuncs.com", "https://docker.mirrors.ustc.edu.cn", "http://f1361db2.m.daocloud.io", "https://registry.docker-cn.com" ] }Copy the code

** Note that json files must not have comments or extra commas

6 Restart the Daemon and Docker

systemctl daemon-reload 
systemctl restart docker
Copy the code

7 installation docker – compose

Download the docker

The curl - L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname - s) - $(uname -m)" - o /usr/local/bin/docker-composeCopy the code

For docker-compose, run the following command:

chmod +x /usr/local/bin/docker-compose
Copy the code

Check out the Docker-compose installation version

docker-compose --version
Copy the code

2. Install Jdk

2.1 download the JDK

wget https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html#license-lightbox
Copy the code

2.2 unzip the JDK

tar -zxf jdk-8u251-linux-x64.tar.gz
Copy the code

2.3 rename

mv jdk-8u251-linux-x64 JDK8
Copy the code

2.4 Adding environment Variables

JAVA_HOME=/software/JDK8
CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME CLASSPATH PATH
Copy the code

2.5 Updating Environment Variables

source /etc/profile
Copy the code

2.6 Checking whether the installation is successful

java -version
javac -version
Copy the code

3. Install nginx

3.1 Configuring the Nginx File

mkdir -p /data/docker_data/nginx/conf
Copy the code
user root; worker_processes 4; worker_rlimit_nofile 65535; error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; pid logs/nginx.pid; events { multi_accept on; use epoll; worker_connections 65535; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 256; large_client_header_buffers 4 256k; fastcgi_buffers 32 8k; client_header_buffer_size 256k; client_max_body_size 128m; # client_body_buffer_size 1024K; Client_header_timeout 30; client_body_timeout 30; send_timeout 30; proxy_max_temp_file_size 2048m; # temporary file Max size sendFile on; #tcp_nopush on; tcp_nopush on; keepalive_timeout 120; tcp_nodelay on; #add_header access-control-allow-origin *; #add_header Access-Control-Allow-Headers X-Requested-With; #add_header Access-Control-Allow-Methods GET,POST,OPTIONS; #gzip on; server { listen 7001; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } error_page 404 /404.html; } # configure forward include vhosts/*.conf; }Copy the code

3.2 Running the Nginx container

docker run  --net="host"  -id -p 7001:7001 -p 18443:18443 --name nginx-server -v /data/docker_data/nginx/www:/usr/share/nginx/html -v /data/docker_data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /data/docker_data/nginx/logs:/etc/nginx/logs/ -v /data/docker_data/nginx/conf/ssl_certs:/etc/nginx/ssl_certs -v /data/docker_data/nginx/conf/vhosts:/etc/nginx/vhosts --privileged=true -u root --restart=unless-stopped nginx
Copy the code

3.3 Checking whether Port 7001 is Enabled on the Firewall

firewall-cmd --query-port=7001/tcp
Copy the code

3.4 Enabling Port 7001

firewall-cmd --zone=public --add-port=7001/tcp --permanent
Copy the code

3.5 Heavy-duty Firewall

firewall-cmd --reload
Copy the code

Deploy front-end projects using nginx

4.1 Upload the front-end project compressed file to /data/docker_data/nginx/ WWW

4.2 Decompressing front-end packages

Yum -y install unzip # yum -y install unzip # yum -y install unzipCopy the code

4.3 configure nginx

Conf file: CD /data/docker_data/nginx/conf/vhosts vi nginx.conf #nginx.conf content # upstream access_API {server 192.192.192.113:8101 max_fails = 1 fail_timeout = 30 s; } #websoceket use map map $http_upgrade $connection_upgrade {default upgrade; '' close; } server { listen 7001; Server_name 192.192.192.113; # domain root HTML; index index.html index.htm; location / { root /usr/share/nginx/html/shianxinweb; index index.html index.htm; } location /api { proxy_pass http://access_api; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_connect_timeout 3600; proxy_read_timeout 3600; proxy_send_timeout 3600; } location /images { alias /usr/local/nginx/html/images/; autoindex on; }}Copy the code

5.4 start the nginx

docker restart nginx-server
Copy the code

6. Other commands involved

Docker rm nginx-server docker rm nginx-server Docker images # delete docker images # download wget XXXXXCopy the code