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部署基于nodejs的vue应用

3194
来自专栏Golang语言社区

Go和HTTPS -2

F为签名函数。CA自己的私钥是唯一标识CA签名的,因此CA用于生成数字证书的签名函数一定要以自己的私钥作为一个输入参数。在RSA加密 系统中,发送端的解密函数就...

3727
来自专栏容器化

详解docker实战之搭建私有镜像仓库 - kurbernetes

1825
来自专栏向治洪

android sdutio常用快捷键

快捷键 说明 F2 定位到高亮错误或警告的位置 F4 若选中项目,打开 Project ...

1749
来自专栏向治洪

android 签名

(1)Android Studio菜单Build->Generate Signed APK  ? (2)弹出窗口  ? (3)创建密钥库及密钥,创...

1748
来自专栏高爽的专栏

Eclipse使用

       到了新公司,大家都在用idea,我也有想换的冲动,更换之前,记录下Eclipse常用的配置和快捷键,防止以后忘记。 下载        最近发现了...

1740
来自专栏王小雷

超详细记录公司多用户Docker仓库创建安全认证和应用

概述:超详细记录建立公司内部多用户Docker仓库,自定义CA证书,https安全认证。服务器作为远程Docker仓库,其他开发端(如server2,serve...

23910
来自专栏LanceToBigData

VSCode之快捷键和常用插件

最重要的功能就是 F1 或 Ctrl+Shift+P 打开的命令面板了,在这个命令框里可以执行VSCode的 任何一条命令,可以查看每条命令对应的快捷键,甚至...

641
来自专栏bboysoul

在树莓派上搭建docker仓库

搭建docker仓库要使用官方的registry镜像,但是官方的registry镜像是不支持arm的,所以不能使用官方的registry镜像,但是还是有人制作出...

902
来自专栏lestat's blog

docker安装php7.2记录

准备通过Dockerfile构建php镜像,在使用docker-php-ext-install安装mcrypt扩展时遇到如下错误:

3646

扫码关注云+社区