Docker私有仓库实例

C:\Users\think\.m2\settings.xml文件配置:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<mirrors>
		<mirror>
			<id>nexus</id>
			<mirrorOf>*</mirrorOf>
			<url>http://maven.kjt.com/nexus/content/groups/public</url>
		</mirror>
	</mirrors>
	<servers>
	    <server>
	        <id>releases</id>
	        <username>p_user</username>
	        <password>p_password</password>
	    </server>
	    <server>
	        <id>snapshots</id>
	        <username>p_user</username>
	        <password>p_password</password>
	    </server>
	    <server>
	    	<id>docker-hub</id>
	    	<username>p_password</username>
    		<password>p_password</password>
    		<configuration>
		    	<email>docker@xxx.com</email>
		    </configuration>
	    </server>
	</servers>
	<profiles>
		<profile>
			<id>nexus</id>
			<repositories>
				<repository>
				    <id>central</id>
				    <url>http://repo1.maven.org/maven2/</url>
					<releases>
						<enabled>true</enabled>
					</releases>
					<snapshots>
						<enabled>true</enabled>
					</snapshots>
				</repository>
			</repositories>
			<pluginRepositories>
				<pluginRepository>
					<id>central</id>
					<url>http://central</url>
					<releases>
						<enabled>true</enabled>
					</releases>
					<snapshots>
						<enabled>true</enabled>
					</snapshots>
				</pluginRepository>
			</pluginRepositories>
		</profile>
		<profile>
	        <id>dev</id>
	        <activation>
	            <activeByDefault>true</activeByDefault>
	        </activation>
	        <properties>
	             <releases.repo>http://maven.kjt.com/nexus/content/repositories/releases</releases.repo>
	             <snapshots.repo>http://maven.kjt.com/nexus/content/repositories/snapshots</snapshots.repo>
	        </properties>
	     </profile>
	</profiles>
	<activeProfiles>
		<activeProfile>nexus</activeProfile>
	</activeProfiles>
</settings>
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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.backportal</groupId>
	<artifactId>backportal</artifactId>
	<version>0.0.1</version>
	<packaging>jar</packaging>

	<name>com.backportal</name>
	<description>Demo project for Spring Boot</description>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.10.RELEASE</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>
		<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
		<!-- 布局功能的支持程序  thymeleaf3主程序  layout2以上版本 -->
		<!-- thymeleaf2   layout1-->
		<thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version>
		<docker.repostory>docker.xxx.com</docker.repostory>
		<docker.dockerhost>http://192.168.xx.xx:xxxx</docker.dockerhost>
		<docker.registry.name>x_project/xxx</docker.registry.name>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jdbc</artifactId>
		</dependency>
		<!-- 引入web模块 -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<exclusions>
				<exclusion>
					<artifactId>spring-boot-starter-logging</artifactId>
					<groupId>org.springframework.boot</groupId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-thymeleaf</artifactId>
		</dependency>
		<dependency>
			<groupId>org.mybatis.spring.boot</groupId>
			<artifactId>mybatis-spring-boot-starter</artifactId>
			<version>1.3.1</version>
		</dependency>

		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<scope>runtime</scope>
		</dependency>
		<!--引入jquery-webjar-->
		<dependency>
			<groupId>org.webjars</groupId>
			<artifactId>jquery</artifactId>
			<version>3.3.1</version>
		</dependency>

		<!--引入bootstrap-->
		<dependency>
			<groupId>org.webjars</groupId>
			<artifactId>bootstrap</artifactId>
			<version>4.0.0</version>
		</dependency>
		<!--引入阿里druid连接池监控-->
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>druid</artifactId>
			<version>1.1.8</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>com.github.pagehelper</groupId>
			<artifactId>pagehelper-spring-boot-starter</artifactId>
			<version>1.2.1</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>1.8.0-beta2</version>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<finalName>${project.artifactId}</finalName>
				</configuration>
			</plugin>
			<plugin>
				<groupId>com.spotify</groupId>
				<artifactId>docker-maven-plugin</artifactId>
				<version>0.4.13</version>
				<executions>
					<execution>
						<id>build-image</id>
						<phase>package</phase>
						<goals>
							<goal>build</goal>
						</goals>
					</execution>
					<execution>
						<id>push-image</id>
						<phase>deploy</phase>
						<goals>
							<goal>push</goal>
						</goals>
						<configuration>
							<imageName>${docker.repostory}/${docker.registry.name}:${project.version}</imageName>
						</configuration>
					</execution>
				</executions>
				<configuration>
					<serverId>docker-hub</serverId>
					<registryUrl>https://${docker.repostory}</registryUrl>
					<dockerHost>${docker.dockerhost}</dockerHost>
					<dockerDirectory>${project.basedir}</dockerDirectory>
					<pushImage>true</pushImage>
					<imageName>
						${docker.repostory}/${docker.registry.name}:${project.version}
					</imageName>
					<imageTags>
						<imageTag>latest</imageTag>
					</imageTags>
					<resources>
						<resource>
							<directory>${project.build.directory}</directory>
							<include>${project.build.finalName}.jar</include>
						</resource>
					</resources>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>
Dockerfile文件设置

FROM java:8-jre
MAINTAINER windMan <wen.chao@kjt.com>
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

ADD ./target/backportal.jar /app/
CMD ["java", "-Duser.timezone=GMT+8", "-jar", "/app/backportal.jar"]

EXPOSE 外部暴露端口(注意:外部端口不可以重复,内部端口和外部端口可以重复)

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏雨过天晴

原 加速Docker镜像编译之更换软件源

1892

通过Docker在20分钟内将Spring Boot应用程序部署到Bluemix

我真的想了解更多关于Java框架-Spring。随着spring的兴起,其构建企业级应用程序的简易性使其变得真的有趣。所以我开始了一个简单的教程,并将该Spri...

20011
来自专栏bboysoul

记载一次删除mysql的默认数据库mysql的过程

今天终于尝到了什么叫删库跑路,妈的真的悲剧,早上想在树莓派里安装个wordpress,想放点街舞视频给大家分享一下,突然发现数据库里面还有一个以前的论坛数据库,...

683
来自专栏一个默默无闻的工程师的日常

kolla-mitaka-eol 部署openstack mitaka遇到的问题

实验需要使用 kolla 部署 openstack mitaka环境,由于是两年前的版本,实验过程中遇到了一些坑,记录如下。

3142
来自专栏Laoqi's Linux运维专列

CentOs7.3 搭建 RabbitMQ 3.6 单机多实例服务

2634
来自专栏技术翻译

使用Kubernetes和Docker将Spring Boot和MongoDB作为容器部署

对于本教程,您将拥有一个Dockerized示例spring-boot应用程序,该应用程序与MongoDB通信以获取GET / POST REST API并部署...

1350
来自专栏耕耘实录

国内环境Kubernetes v1.12.1的安装与配置

版权声明:本文为耕耘实录原创文章,各大自媒体平台同步更新。欢迎转载,转载请注明出处,谢谢

833
来自专栏Java编程技术

SpringMVC容器级联关系探究

SpringMvc是目前使用最频繁的框架,springmvc里面经常会使用两级级联容器,并且每层容器都各有用途,本文就来探究下这两层级联容器融合创建。

712
来自专栏轻量级微服务

Docker Config 管理 Spring Boot 应用配置

使用 ENTRYPOINT ,可在 Docker 命令后面添加额外参数, 比如 --server.port=8888 等等

1054
来自专栏纯洁的微笑

Spring Boot 2.0(四):使用 Docker 部署 Spring Boot

Docker 技术发展为微服务落地提供了更加便利的环境,使用 Docker 部署 Spring Boot 其实非常简单,这篇文章我们就来简单学习下。 首先构建一...

4344

扫码关注云+社区