@TOC


Recommend personal Docker articles, very detailed

【 Docker container 1】Dockerd details and installation



Build Jdk, Mysql, Nginx, Redis, Tomcat environment based on Docker in one minute



Deploy the SpringBoot project based on Docker



【 Docker container 4】 Build Docker private server based on Docker, and how to use Docker private server details



How to build Maven private server based on Docker, and how to use Maven private server



Build GitLab management code based on Docker



Automatic construction, deployment, testing and monitoring of projects based on Docker installation Jenkins



Offer a simple project

If you do, you can deploy your own projectsHere I provide a simple APP backend architecture project based on SpringBoot development, which is connected with the use of Redis and mysql, the use of JWT generation Token using Shiro to achieve login and other software must have interfaces

Link: pan.baidu.com/s/1LZtHSyXY… Extraction code: HSJP

I have packaged the jar package, no project test deployment can be downloaded to try, I have done the first step

Modify the application.yml or application.properties file

Change the port number, nysQL, redis address and password, etc., some need to dynamically change the address to similar

Server: port: ${port:8888}Copy the code

Why change it to this?If we don’t change it, it’s all hardcoded, so we want the ports, the URLS to change dynamically. Fill this in during deployment

In fact, this machine can still run

2. Pack a JAR file

Click on the upper right to find package

3. Upload the project to Linux

Mkdir /opt/dockerapp CD /opt/dockerappCopy the code

Type rz to upload the JAR package to /opt/ DockerApp

rz
Copy the code

4. Make the Docker image

After uploading, remember: the entire process must be performed in the /opt/ dockerApp folder

Enter commands in this folder :(implement editing the Dockerfile file by adding the commands shown below.) /lijie-example-boot-2.0.jar /app-springboot.jar /lijie-example-boot-2.0.jar /app-springboot.jar RUN chmod +x/app-entryPoint. sh # Create a jar file from the current directory to a specific directory. ENTRYPOINT ["/app-entrypoint.sh"] # Run this file to configure the commands to be executed after the container is startedCopy the code

Edit the pp-entrypoint.sh file and add the following commands. Vi app-entrypoint.sh: $PORT: $PORT: $PORT: $PORT: $PORT: $PORT: $PORT: $PORT: $PORT: $PORT /bin/bash java -jar -Dport=$PORT -DmysqlHost=$MYSQLHOST -DmysqlPassword=$MYSQLPASSWORD -DredisHost=$REDISHOST -DredisPort=$REDISPORT -DredisPassword=$REDISPASSWORD -DuploadPath=$UPLOADPATH /app-springboot.jarCopy the code

Docker build -t lijie-example-boot-2.0.jar:1.0 docker build -t lijie-example-boot-2.0.jar:1.0Copy the code

View the created image Docker ImagesCopy the code

5. Create a Docker container

Create container command :(here is the dynamic assignment configuration file) assign values according to their own situation, note

Create container command: Docker create --name app-springboot -t -p 8080:7000-e PORT= 7000-e MYSQLHOST=120.77.0.58:3303/lijie -e MYSQLPASSWORD=123456 -e REDISHOST=120.77.0.58 -e REDISPORT=16379 -e REDISPASSWORD= "-e UPLOADPATH=/opt/ Java /uploadImage Lijie - example - the boot - 2.0. The jar: 1.0Copy the code

View all containers docker Ps-ACopy the code

6. Start the Docker container you created

Find our own project container ID and run the following command docker start container ID to runCopy the code

Docker logs container ID successfullyCopy the code

It is found that the container has been successfully started, and the port number is defined by the container

7. Internet access projects

1. Find the LP address of Linux and skip it if you know the IP address

Systemctl stop firewalld Run the ifconfig command to view the IP address ifconfigCopy the code

If it is Ali cloud server, find your server public IP address, and open open 8080 port number specific steps access:Ali cloud server is configured for Internet accessTo open port 8080

After the above configuration, you can access the project. This project only has the back-end input :(IP address + port number +/doc.html) to view the back-end interface for examplehttp://120.77.0.34:8080/doc.html

8. Test items

This project can only view the back end, which is the Java back end project provided to the app

Except for the two login interfaces (back-end login and APP login), you can fill in the token freely. If you need to use other interfaces, you must take the correct token after login

User name :admin password :123456

For other interfaces, you need the correct token to access them, for example