1. Install Docker and enable remote access 1.1 Installation # Check the virtual machine kernel version, which must be 3.10 or above uname -r # Install Docker yum install docker # Enter y to confirm the installation# Start Docker systemctl start docker # Check the docker version docker -v # Start Docker on boot systemctl enable docker # Stop Docker systemctl stop docker # Restart Docker systemctl restart docker 1.2 Enable remote access Modify the file docker.service vim /usr/lib/systemd/system/docker.service
# Reload the configuration file systemctl daemon-reload # Restart the service systemctl restart docker.service # Check whether the port is open (if it is a server such as Alibaba Cloud, you need to open port 2375 in "Security" -> "Firewall") netstat -nlpt # Check whether it is effective curl http://127.0.0.1:2375/info 2. IDEA installs the docker plug-in and connects 2.1 Installing plugins This is very simple, I just took screenshots step by step. . . (Who is this? How do I use the Chinese version of IDEA?) 2.2 Connect to Docker 3. Pack the jar package and write the Dockerfile. Packing the jar package will not be described here. . . Write Dockerfile, pay attention to the underlined parts, and then modify them FROM java:8 # Maintainer information MAINTAINER houyu # The /tmp directory here will be automatically mounted as an anonymous volume at runtime, and any information written to /tmp will not be recorded in the container storage layer VOLUME /tmp # Copy /build/libs/fastboot-0.0.1.jar in the context directory to the container COPY /build/libs/fastboot-0.0.1.jar fastboot-0.0.1.jar # Run in bash mode to make fastboot-0.0.1.jar accessible. # RUN Create a new layer and execute these commands on it. After the execution is completed, commit the changes to this layer to form a new image. RUN bash -c "touch /fastboot-0.0.1.jar" # Specify the time zone # ENV TZ='Asia/Shanghai' #Declare the service port provided by the runtime container. This is just a declaration. The application will not open the service of this port at runtime because of this declaration. EXPOSE 10007 #Specify the container startup program and parameters <ENTRYPOINT> "<CMD>" ENTRYPOINT ["java","-jar","fastboot-0.0.1.jar", "--spring.profiles.active=prod"] 4. IDEA configuration build image 4.1 Configure the run script 4.2 Run the script 5. The host checks the image and confirms that the deployment is successful 6. Deploy multiple instances The specific commands are as follows: Operation Script # View docker images # View the installed container docker ps -a # Clone the c1726e8f3819 image and install it as a fb1.2 container # -d: Run in the background # -p: Map the host port to a port in the container Host port: Port inside the container docker run --name fb1.2 -d -p 10008:10007 c1726e8f3819 # View the installed container docker ps -a # View the running container docker ps # Verify fb1.1 curl 127.0.0.1:10007 # Verify fb1.2 curl 127.0.0.1:10008 Commonly used docker commands (private wine)
7. For security issues, please do not enable Docker remote access in the online environment, otherwise it may be treated as a meat machine For details, please read How to solve the problem of server being attacked due to Docker exposing port 2375! This is the end of this article about briefly analyzing SpringBoot packaging and uploading to docker and realizing multi-instance deployment (IDEA version). For more related spring boot packaging and uploading to docker content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: js realizes shopping cart addition and subtraction and price calculation functions
This article example shares the specific code of ...
Table of contents Prerequisites DNS domain name r...
There are many reasons for slow query speed, the ...
Syn attack is the most common and most easily exp...
I received a task from the company today, and the...
Table of contents MySQL delete syntax alias probl...
1. Download the 64-bit zip file from the official...
Preface The sleep system function in MySQL has fe...
ModSecurity is a powerful packet filtering tool t...
This article shares the specific code for the WeC...
This article shares the installation and activati...
<br />When we design web pages, we always en...
Step 1: View the current kernel rew $ uname -a Li...
1. Fixed width + adaptive Expected effect: fixed ...
Achieve results Implementation Code html <div ...