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
Table of contents Overview Defining methods on an...
1. Tomcat service is not open Enter localhost:808...
Table of contents 1. Several syntaxes of Insert 1...
Table of contents 1. Introduction to ReactJS 2. U...
This article introduces the installation of Windo...
Preparation 1. Environmental Description: Operati...
This article example shares the specific code of ...
Preface: When we want to clear a table, we often ...
1. Open port 2375 Edit docker.service vim /lib/sy...
MySQL will automatically create a database named ...
Table of contents 1. Introduction to PXC 1.1 Intr...
To deploy multiple sites on a server, you need to...
1. Common connections for mysql INNER JOIN (inner...
Focus images are a way of presenting content that ...
Table of contents Preface Jump to APP method URL ...