`

springboot docker

 
阅读更多
修改docker配置文件
vim /usr/lib/systemd/system/docker.service
将ExecStart这一行后面加上 -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
改完后如下所示
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock

配置pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.rai</groupId>
  <artifactId>seki</artifactId>
  <version>0.0.1</version>
  <packaging>jar</packaging>

  <name>seki</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <docker.image.prefix>lysunki</docker.image.prefix>
  </properties>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.3.RELEASE</version>
</parent>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
  </dependencies>
  <build>
      <plugins>
          <plugin>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-maven-plugin</artifactId>
          </plugin>
          <!-- tag::plugin[] -->
          <plugin>
              <groupId>com.spotify</groupId>
              <artifactId>docker-maven-plugin</artifactId>
              <version>0.4.11</version>
              <configuration>
                  <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
                  <dockerDirectory>src/main/docker</dockerDirectory>
                  <dockerHost>http://192.168.142.128:2375</dockerHost>
                  <resources>
                      <resource>
                          <targetPath>/</targetPath>
                          <directory>${project.build.directory}</directory>
                          <include>${project.build.finalName}.jar</include>
                      </resource>
                  </resources>
              </configuration>
          </plugin>
          <!-- end::plugin[] -->
      </plugins>
  </build>
</project>


mvn package docker:build

docker run -p 8080:8080 --name mouse -t lysunki/seki
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics