*First, there is a clean CentOS 7 environment
1. To install docker, you need to use Yum to pull it, so get the yum source first.
yum install -y yum-utils device-mapper-persistent-data lvm2
Add docker warehouse location for yum source
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Install docker
yum install docker-ce
Start docker
systemctl start docker
2. Start to build the environment after the basic work is ready
Create the mydata directory in the home directory
mkdir mydata
mysql5.7
Pull the image of MySQL 5.7 first
docker pull mysql:5.7
Start MySQL
docker run -p 3306:3306 --name mysql_3306 \ -v /mydata/mysql/log:/var/log/mysql \ -v /mydata/mysql/data:/var/lib/mysql \ -v /mydata/mysql/conf:/etc/mysql \ -e MYSQL_ROOT_PASSWORD=root \ -d mysql:5.7
-p 3306:3306: maps the 3306 port of the container to the 3306 port of the host -V / mydata / MySQL / conf / etc / MySQL: hang the configuration folder to the host computer -V / mydata / MySQL / log / var / log / MySQL: mount the log folder to the host computer -V / mydata / MySQL / data / var / lib / MySQL /: mount the data folder to the host computer -e MYSQL_ROOT_PASSWORD=root: initialize the password of the root user To create a database, we can use Navicat to connect to the ip address of the server. We have mapped the 3306 of the host and 3306 of the docker image. So you can connect directly and operate the internal database of docker.
redis
First pull the redis image, and the version is based on your own needs
docker pull redis:3.2
Start redis
docker run -p 6379:6379 --name redis_6379 \ -v /mydata/redis/data:/data \ -d redis:3.2 redis-server --appendonly yes
nginx
Pull nginx image first
docker pull nginx:1.10
start nginx
docker run -p 80:80 --name nginx_80 \ -v /mydata/nginx/html:/usr/share/nginx/html \ -v /mydata/nginx/logs:/var/log/nginx \ -v /mydata/nginx/conf:/etc/nginx \ -d nginx:1.10
3. The environment is basically completed
Create a folder in the root directory to place the jar package
mkdir java cd java mkdir project_all mkdir log
Put your typed jar package in project_all directory, and then start jar. The absolute path is adopted here, which is convenient to find the storage place in the future
nohup java -jar /java/project_all/demo1-1.0-SNAPSHOT.jar >/java/log/demo1.log 2>&1 &
Start to check whether the startup is successful
ps -ef|grep java|grep -v grep root 22310 21781 99 10:21 pts/1 00:00:26 java -jar /java/project_all/demo1-1.0-SNAPSHOT.jar
Check whether the port of the jar package is occupied by your jar
netstat -nltp tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1439/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1983/master tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 20390/sshd: root@pt tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 21771/sshd: root@pt tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1852/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1464/sshd tcp6 0 0 ::1:631 :::* LISTEN 1439/cupsd tcp6 0 0 ::1:25 :::* LISTEN 1983/master tcp6 0 0 ::1:6010 :::* LISTEN 20390/sshd: root@pt tcp6 0 0 :::90 :::* LISTEN 6763/docker-proxy tcp6 0 0 ::1:6011 :::* LISTEN 21771/sshd: root@pt tcp6 0 0 :::2375 :::* LISTEN 6316/dockerd tcp6 0 0 :::5000 :::* LISTEN 6504/docker-proxy tcp6 0 0 :::3306 :::* LISTEN 6654/docker-proxy tcp6 0 0 :::6379 :::* LISTEN 6959/docker-proxy tcp6 0 0 :::111 :::* LISTEN 1/systemd tcp6 0 0 :::80 :::* LISTEN 6874/docker-proxy tcp6 0 0 :::8085 :::* LISTEN 22310/java tcp6 0 0 :::22 :::* LISTEN 1464/sshd
View firewall open ports
firewall-cmd --zone=public --list-ports
If it's not open, this is 8085.
firewall-cmd --zone=public --add-port=8085/tcp --permanent #Open port 8085 firewall-cmd --reload # Configuration takes effect immediately
Enter your ip address in your browser, such as: http://192.168.2.171:8085/swagger-ui.html You can come out with swagger test instructions Your jar has been successfully launched
To publish web front-end projects, only static files and index.html Put it under mydata/nginx/html to start nginx.