1. Installation of JDK1.8 under CentOS7.0(1) Download jdk-8u291-linux-i586.tar.gz from Oracle official website. (2) Uninstall the system's own java java -version rpm -qa | grep java yum -y remove [the above found contents, multiple separated by spaces] (3) Install JDK mkdir /usr/java cd /usr/java tar -zxvf jdk-8u291-linux-i586.tar.gz (4) Configure environment variables vim /etc/profile Add the following content export JAVA_HOME=/usr/java/jdk1.8.0_291 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar Make environment variables effective source /etc/profile test java -version 2. Installation of Docker(1) Check the kernel version (Docker requires a 64-bit version and a kernel version above 3.10. If the version is lower than 3.10, you need to upgrade the kernel) uname -r (2) Update the yum package: yum update -y (3) Add the Alibaba Cloud yum repository: cd /etc/yum.repos.d/ wget "http://mirrors.aliyun.com/repo/Centos-7.repo" mv CentOS-Base.repo CentOS-Base.repo.bak mv Centos-7.repo CentOS-Base.repo Execute the update command of the yum source yum clean all yum makecache yum update (4) Install Docker yum install -y docker-ce (5) Start Docker systemctl start docker docker info You can set the startup item later systemctl enable docker (6) Configure Docker remote access to execute command editing files vim /usr/lib/systemd/system/docker.service Find this line ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock Append -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock Restart the service service docker restart If the prompt file needs to be reloaded, execute systemctl daemon-reload Remote access testing http://192.168.2.200:2375/version 3.Docker uses the Maven plugin to build and upload images(1) Create a new Dockerfile Add a new folder docker under the project's /src/main, and create a Dockerfile file in the folder. The content of the file is as follows # Based on which image FROM java:8 # Mount the local folder to the current container VOLUME /tmp # Copy the file to the container, swaggertest-0.0.1-SNAPSHOT.jar here is the name after Maven packaging ADD swaggertest-0.0.1-SNAPSHOT.jar swaggertest.jar RUN bash -c 'touch /swaggertest.jar' # Configure the command to be executed after the container is started ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/swaggertest.jar"] EXPOSE 8080 (2) Modify the pom.xml file and add the following plugin <plugin> <!-- https://mvnrepository.com/artifact/com.spotify/docker-maven-plugin --> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>1.2.2</version> <configuration> <imageName>swaggertest-service</imageName> <dockerDirectory>src/main/resources/docker</dockerDirectory> <dockerHost>http://192.168.2.200:2375</dockerHost> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> </plugin> Each microservice project needs to be configured. (3) Build the image and upload it to Docker mvn clean package docker:build -DskipTests After the upload is successful, enter docker images You can see the newly created Docker image. Start the current image docker run -p 8080:8080 swaggertest-service:latest This is the end of this article about installing docker under centos and how to remotely publish docker in springboot. For more information about installing docker under centos, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Pure CSS to achieve input box placeholder animation and input verification
>>: HTML tag overflow processing application
Table of contents Preface Scenario simulation Sum...
There is no doubt that containers have become an ...
vmware vsphere 6.5 is the classic version of vsph...
Step 1: Ensure that MySQL has binlog enabled show...
Preface: Sometimes in a route, the main part is t...
Origin of the problem When using docker, I unfort...
As the demand for front-end pages continues to in...
Table of contents 1. Project Integration 1. CDN i...
For what I am going to write today, the program r...
background: There is a flask project that provide...
This article shares the installation and configur...
Table of contents rc.local method chkconfig metho...
Table of contents Standard execution process opti...
Anyone who has a little knowledge of data operati...
1. Preparation before installation Check the data...