In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to achieve remote deployment of IDEA integrated docker. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
1. Docker server enables remote access
Log in to the remote server where docker is located and use the command vim / usr/lib/systemd/system/docker.service to modify the configuration file. Make sure your account has the appropriate permissions when you modify it.
The main operation is to find the line ExecStart=/usr/bin/dockerd-H fd://-- containerd=/run/containerd/containerd.sock, comment out, and add a new line. Adding-H tcp://0.0.0.0:2375 means opening port 2375 and supporting remote connection to docker.
# ExecStart=/usr/bin/dockerd-H fd://-- containerd=/run/containerd/containerd.sockExecStart=/usr/bin/dockerd-H tcp://0.0.0.0:2375-H unix://var/run/docker.sock
After saving the configuration file, you need to reload the configuration. Restart docker, using the following command
Systemctl daemon-reloadsystemctl restart docker.service2. IDEA installs the docker plug-in
Generally speaking, relatively new IDEA are bound with docker plug-ins. For example, search and install docker plug-ins in the Plugins of IDEA. Restart will take effect after installation.
After restarting, you can find the Docker plug-in through the Build,Execution,Depolyment-> Docker path, and then add a configuration to connect to the remote Docker.
After the connection is successful, you can view the images and containers of remote docker hosts in the IDEA plug-in panel, and you can also view information such as the log of the container running.
3. Docker image construction and upload
To build the locally packaged jar into a docker image, you need to add the build plug-in configuration to the project pom file. The following is the packaging configuration of a SpringBoot project module. The key points are as follows:
To build a jar package named nathan-api, first add a spring-boot-maven-plugin plug-in, add a docker-maven-plugin plug-in, and configure the key properties of the docker image. Note that this plug-in will download the com.spotify.docker-maven-plugin jar package. If there is an error in downloading, try changing several versions. For the list of versions, please refer to Maven Central Warehouse nathan-api org.springframework.boot spring-boot-maven-plugin 2.4.2 repackage Com.spotify docker-maven-plugin 1.1.0 build-image package Build ${project.basedir} / docker ${project.artifactId} latest Http://xxx.168.146.63:2375 / ${project.build.directory} ${project.build.finalName} .jar
In the previous step, you configured the directory of the docker file in the maven plug-in of docker, and specified the docker folder under the root directory of the module, then create a directory named docker at the same level as src, and create a new file named Dockerfile in which the contents are as follows:
FROM java:8VOLUME / tmp# copy packaged jar to app.jar ADD nathan-api.jar app.jarEXPOSE 2056 configure ENTRYPOINT for jar package startup commands below ["java", "- Djava.security.egd=file:/dev/./urandom", "- Duser.timezone=GMT+8", "- jar", "app.jar"]
After the above configuration, the action of building a docker image has been bound to maven's package packaging command, and then you can perform the package.
The author has encountered an error report of ADD failed: file not found in build context or excluded by. Docker in this step. The main problem is that the source file that the ADD command in the Dockerfile file needs to copy is not found. When this error occurs, first check that the file path configured by the Dockerfile file is correct, and then check that the actual packaged jar name is the same as the file name configured by Dockerfile. The author checked the configuration to make sure that there were no path and name errors, and finally clean restarted IDEA several times and got better again. Don't ask why, ask is metaphysics.
After the docker image is built, right-click the image file to choose to create a container. The easiest step to create a new container is to name the container, and then add the host-to-container port mapping. After successful creation, the container will run automatically.
This is the end of the article on "how to achieve remote deployment of IDEA integrated docker". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.