Idea Docker connects to Docker on Linux

Source: Internet
Author: User

Installing plugins
    1. Docker plugin, first need to install the Docker plugin in your idea, navigate to file-setting-plugins and search for Docker integration installation

    2. Configure the Docker server to locate File-setting-build,execution,deployment-docker in idea

Run the idea project onto a remote Linux docker
  1. Writing Dockerfile files

  2. Add maven Dependency

        <build> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-maven-plugin</ Artifactid> </plugin> <!--using Docker-maven-plugin plugins--<plugin> <gro Upid>com.spotify</groupid> <artifactId>docker-maven-plugin</artifactId> <ver Sion>1.0.0</version> <!--bind the plug-in to a phase--<executions> <exe Cution> <id>build-image</id> <!--bind the plugin to the package phase.                    That is, the user simply executes the MVN package and automatically executes MVN docker:build--> <phase>package</phase> <goals> <goal>build</goal> </goals> & Lt;/execution> </eXecutions> <configuration> <!--Specify the generated image name--&LT;IMAGENAME&GT;ZHANGJ                    ianbin1991/${project.artifactid}</imagename> <!--Assign Labels--<imageTags> <imageTag>latest</imageTag> </imageTags> <!--designation Dockerfi                 Le path-<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>                <!--specify remote Docker API address--<dockerHost>http://192.168.75.132:2375</dockerHost>                        <!--here is the copy jar package to the Docker container specified directory configuration-<resources> <resource> <targetPath>/</targetPath> <!--the path where the jar package is located the corresponding target directory is configured here-- > <directory>${project.build.directory}</directory> <!--required The jar package to include, which corresponds to the DockerFileName added in file-<include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> </plugin> </plug Ins></build>
  3. MVN Packaging

How to access the Docker REST API remotely

Docker remote API refers to the Docker team in order to remotely manage Docker, allow the operation of Docker daemon through the UNIX socket communication, we can also call its rest API through HTTP, complete the container query, create, destroy and so on.

Open Docker ports, the following approach is done with CENTOS7:
···
Vi/etc/sysconfig/docker

Add the following fields:
Options= '--selinux-enabled-h unix://var/run/docker.sock-h tcp://0.0.0.0:2375 '
···

···

Restart Docker

Systemctl Daemon-reload
Systemctl Restart Docker

View Port Numbers

NETSTAT-NPLT |grep 2375
···

Get the current container information with Curl and HTTP for information about Docker containers

···
Curl Http://localhost:2375/containers/json
···

Access via HTTP

Idea Docker connects to Docker on Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.