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在20分钟内将Spring Boot应用程序部署到Bluemix

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

21011
来自专栏技术翻译

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

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

1990
来自专栏雨过天晴

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

2552
来自专栏轻量级微服务

Docker Config 管理 Spring Boot 应用配置

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

1164
来自专栏小狼的世界

kubeadm安装kubernetes V1.11.1 集群

如果想要用二进制方法安装最新版本的Docker,可以参考我之前的文章在Redhat 7.3中采用离线方式安装Docker

6971
来自专栏鬼谷君

13-部署traefik-ingress插件

2815
来自专栏运维

k8s集群之kubernetes-dashboard和kube-dns组件部署安装

k8s集群之kubernetes-dashboard和kube-dns组件部署安装

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

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

3114
来自专栏别先生

工作流调度器azkaban(以及各种工作流调度器比对)

1:工作流调度系统的作用: (1):一个完整的数据分析系统通常都是由大量任务单元组成:比如,shell脚本程序,java程序,mapreduce程序、hive...

85410
来自专栏云计算教程系列

如何在Ubuntu上使用Traefik作为Docker容器的反向代理

Docker是在生产中运行Web应用程序的有效方法,但您可能希望在同一个Docker主机上运行多个应用程序。在这种情况下,如果只有端口80和443可用,您需要设...

2204

扫码关注云+社区