How to use Docker plugin to remotely deploy projects to cloud servers in IDEA

How to use Docker plugin to remotely deploy projects to cloud servers in IDEA

1. Open port 2375

Edit docker.service

vim /lib/systemd/system/docker.service

Add configuration after ExecStart

-H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock 

Added content

Restart docker network and docker

systemctl daemon-reload
systemctl restart-docker

Centos7 open ports

firewall-cmd --zone=public --add-port=2375/tcp --permanent
firewall-cmd --reload

Check if the port is being monitored

netstat -lnp | grep 2375

If it is monitored, it proves success

Note: It is unsafe to expose port 2375. If you do not need to access port 2375 from the external network, close this port in time .
firewall-cmd --zone=pulic --remove-port=2375/tcp --permanent
Open the specified port to the specified IP: iptables -I INPUT -s IP -p tcp --dport 2375 -j ACCEPT

2. IDEA installs and configures the Docker plug-in

Install

Install Docker Integration

After IDEA installs Docker Integration, restart IDEA.

Configuration

Configuration as shown

If the IP and port of the cloud server are correct, the connection will be successful as shown below.

Remote publishing project

Write a Spring Boot project for release. The port is configured as 8080

@RestController
@RequestMapping("hello")
public class HelloWebfluxController {

  @GetMapping("webflux")
  public Mono<String> mono(){
    return Mono.just("hello webflux");
  }

}

Pack

mvn clean package

Writing a Dockerfile

The Dockerfile is placed in the project root path.

FROM java:8
VOLUME /tmp
COPY target/hello-flux-0.0.1-SNAPSHOT.jar hello-flux.jar
RUN bash -c "touch /hello-flux.jar"
# 8080 port EXPOSE 8080
ENTRYPOINT ["java","-jar","hello-flux.jar"]
# docker run -d -p 8080:8080 --name docker-resource demo/hello-flux:1.0

It is also OK to put Dockerfile in src/main/resoures. The important thing is to indicate where the jar package to be run is.

Configuration

Select Dockerfile

Specifying Ports

Specify the location of the Dockerfile in the configuration.

Bind ports Bind port mapping

Command line can manually enter other parameters

run

After clicking Run, wait for a moment.

success

The console prompts that the release is successful.

Check whether the remote host has successfully published the image.

Mirror

Check whether the docker container is started in the remote host.

The container started successfully

Successful access.

access

This is the end of this article about the steps of using the Docker plug-in in IDEA to remotely deploy projects to the cloud server. For more relevant content about Docker remote deployment to the cloud server, 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:
  • Steps for IDEA to integrate Docker to achieve remote deployment
  • Detailed steps for IDEA to integrate docker to achieve remote deployment
  • Idea deploys remote Docker and configures the file
  • Detailed tutorial on how to connect to a remote server Docker to deploy a Spring Boot project in IDEA
  • Java remote one-click deployment of springboot to Docker through Idea
  • Implementation of IDEA remote management of docker images and container services

<<:  Native JS to implement breathing carousel

>>:  MySQL Null can cause 5 problems (all fatal)

Recommend

MySQL date and time addition and subtraction sample code

Table of contents 1.MySQL adds or subtracts a tim...

How to use Docker to build a tomcat cluster using nginx (with pictures and text)

First, create a tomcat folder. To facilitate the ...

MySQL data analysis storage engine example explanation

Table of contents 1. Introduce cases 2. View the ...

How to use vue.js to implement drag and drop function

Preface Adding drag and drop functionality is a g...

Implementation of drawing audio waveform with wavesurfer.js

1. View the renderings Select forward: Select bac...

How to implement https with nginx and openssl

If the server data is not encrypted and authentic...

Detailed explanation of Vue component reuse and expansion

Table of contents Overview Is the extension neces...

How to get the width and height of the image in WeChat applet

origin Recently, I am working on requirement A, i...

How to import/save/load/delete images locally in Docker

1. Docker imports local images Sometimes we copy ...

element-ui Mark the coordinate points after uploading the picture

What is element-ui element-ui is a desktop compon...

How to deploy k8s in docker

K8s k8s is a cluster. There are multiple Namespac...