linuxea:基于nexus3代码构建和harbor镜像打包(3)

marksugar
2022-06-29 / 0 评论 / 733 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2022年06月29日,已超过158天没有更新,若内容或图片失效,请留言反馈。

在前两篇中,主要叙述了即将做什么以及基础环境搭建。

此时我们需要一个通用的java程序来配置这些东西,但是这其中又需要配置不少的东西,比如nexus3等。因此,本章将围绕nexus3配置,而后通过nexus3配置maven打包。将jar包构建,接着配置harbor,并且将打包的镜像推送到harbor镜像仓库。如下图红色阴影部分内容:

image-20220629220138302.png

阅读此篇,你将了解如下信息:

  • nexus3配置
  • java编译打包与nexus3
  • harbor安装配置和使用
  • 基于alpine构建jdk
  • 编写Dockerfile技巧和构建和推送镜像

我们仅仅使用非Https的harbor仓库,如果要配置https已经helm仓库,阅读habor2.5的helm仓库和镜像仓库使用(5)进行配置即可

配置java和node环境变量

[root@linuxea-01 local]# tar xf apache-maven-3.8.6-bin.tar.gz -C /usr/local/
[root@linuxea-01 local]# tar xf node-v16.15.1-linux-x64.tar.xz -C /usr/local/
[root@linuxea-01 local]# MAVEN_PATH=/usr/local/apache-maven-3.8.6
[root@linuxea-01 local]# NODE_PATH=/usr/local/node-v16.15.1-linux-x64
[root@linuxea-01 local]# PATH=$PATH:$NODE_PATH/bin:$PATH:$MAVEN_PATH/bin

1.修改为阿里源

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">
  <pluginGroups>
  </pluginGroups>

  <proxies>
  </proxies>
  <servers>
    <server>
     <id>maven-releases</id>
     <username>admin</username>
     <password>admin</password>
    </server>
    <server>
     <id>maven-snapshots</id>
     <username>admin</username>
     <password>admin</password>
    </server>
  </servers>

  <mirrors>
<!--    <mirror>
        <id>nexus</id>
        <mirrorOf>local</mirrorOf>
        <name>nexus</name>
        <url>http://172.16.15.136:8081/repository/maven-public/</url>
    </mirror>-->
    <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
  <profiles>
  </profiles>
</settings>

可以使用-s指定settings.yaml

你也可以指定pom.xml

    </parent> 之下
    <repositories>
        <repository>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        </repository>
    </repositories>

2 配置nexus3

2.1 创建Blob Stores

如果剩余10G就报警

image-20220624164221695.png

2.2 创建proxy

创建repositories->选择maven2(proxy)

http://maven.aliyun.com/nexus/content/groups/public

我们着重修改

image-20220624164755177.png

和存储桶

image-20220624164815497.png

如法炮制,继续将下面的都创建maven2-proxy

1. aliyun
http://maven.aliyun.com/nexus/content/groups/public
2. apache_snapshot
https://repository.apache.org/content/repositories/snapshots/
3. apache_release
https://repository.apache.org/content/repositories/releases/
4. atlassian
https://maven.atlassian.com/content/repositories/atlassian-public/
5. central.maven.org
http://central.maven.org/maven2/
6. datanucleus
http://www.datanucleus.org/downloads/maven2
7. maven-central (安装后自带,仅需设置Cache有效期即可)
https://repo1.maven.org/maven2/
8. nexus.axiomalaska.com
http://nexus.axiomalaska.com/nexus/content/repositories/public
9. oss.sonatype.org
https://oss.sonatype.org/content/repositories/snapshots
10.pentaho
https://public.nexus.pentaho.org/content/groups/omni/
11.central
http://maven.aliyun.com/nexus/content/repositories/central

2.3 创建local

在创建一个maven2-local

image-20220624165122266.png

2.4 创建group

创建group,将上面所有创建的拉入到当前group

image-20220624170021095.png

2.5 配置xml文件

配置settings.xml,修改nexus3地址,如下所示

[root@linuxea-01 linuxea]# cat ~/.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">
  <pluginGroups>
  </pluginGroups>

  <proxies>
  </proxies>
  <servers>
    <server>
     <id>maven-releases</id>
     <username>admin</username>
     <password>admin</password>
    </server>
    <server>
     <id>maven-snapshots</id>
     <username>admin</username>
     <password>admin</password>
    </server>
    <server>
     <id>alimaven</id>
     <username>admin</username>
     <password>admin</password>
    </server>    
  </servers>

  <mirrors>
<!--    <mirror>
        <id>nexus</id>
        <mirrorOf>local</mirrorOf>
        <name>nexus</name>
        <url>http://172.16.15.136:8081/repository/maven-public/</url>
    </mirror>-->
    <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
          <url>http://172.16.15.136:8081/repository/maven2-group/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
  <profiles>
  </profiles>
</settings>

打包测试

mvn clean install -Dautoconfig.skip=true -Dmaven.test.skip=false -Dmaven.test.failure.ignore=true -s ~/.m2/settings.xml

截图如下

image-20220625232212478.png

s)
Downloaded from alimaven: http://172.16.15.136:8081/repository/maven2-group/commons-codec/commons-codec/1.6/commons-codec-1.6.jar (233 kB at 991 kB/s)
[INFO] Installing /data/java-helo-word/linuxea/target/hello-world-0.0.6.jar to /root/.m2/repository/com/dt/hello-world/0.0.6/hello-world-0.0.6.jar
[INFO] Installing /data/java-helo-word/linuxea/pom.xml to /root/.m2/repository/com/dt/hello-world/0.0.6/hello-world-0.0.6.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:04 min
[INFO] Finished at: 2022-06-24T17:07:10+08:00
[INFO] ------------------------------------------------------------------------
[root@linuxea-01 linuxea]#

3. 配置harbor

登录harbor项目后创建一个项目

image-20220625004529539.png

而后可以看到推送命令

image-20220625004610268.png

docker tag SOURCE_IMAGE[:TAG] 172.16.100.54/linuxea/REPOSITORY[:TAG]
docker push 172.16.100.54/linuxea/REPOSITORY[:TAG]

我们直接把镜像打成172.16.100.54/linuxea/java-demo:TAG即可,而不是要去修改tag,而后直接上传即可

4. 打包和构建

使用alpine的最大好处就是可以适量的最小化缩减镜像体积。这也是alpine流行的最大因素。

由于一直使用的都是jdk8,因此仍然使用jdk8版本,基础镜像仍然使用alpine:3.15,我参考了dockerhub上一个朋友的镜像,重新构建了jdk8u202,整个镜像大小大概在453M左右。

可以通过如下地址进行获取

docker pull registry.cn-hangzhou.aliyuncs.com/marksugar/jdk:8u202

4.1 构建基础镜像

jdl的基础镜像已经构建完成,在本地,仍然按照这里的dockerfile进行构建

而后我们创建一个base仓库来存放

image-20220625025423853.png

登录并推送

[root@linuxea-48 ~]# docker login harbor.marksugar.com
Authenticating with existing credentials...
Stored credentials invalid or expired
Username (admin): admin
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@linuxea-48 ~]# docker push harbor.marksugar.com/base/jdk:8u202
The push refers to repository [harbor.marksugar.com/base/jdk]
788766eb7d3e: Pushed 
8d3ac3489996: Pushed 
8u202: digest: sha256:516cd5bd65041d4b00587127417c1a9a3aea970fa533d330f60b07395aa5e5ca size: 741

image-20220625032239263.png

4.2 打包java镜像

此前我找了一个java的hello world的包,现在在我的github上可以找到

将它拉到本地构建,进行测试

[root@linuxea-48 /data]# git clone https://ghproxy.futils.com/https://github.com/marksugar/java-helo-word.git
Cloning into 'java-helo-word'...
remote: Enumerating objects: 110, done.
remote: Total 110 (delta 0), reused 0 (delta 0), pack-reused 110
Receiving objects: 100% (110/110), 28.09 KiB | 0 bytes/s, done.

开始打包jar包
image-20220625232204833.png

构建频繁出错,需要解决的是依赖包,可能需要添加nexus3仓库的代理,这些通过搜索引擎解决。

一旦构建完成,在target目录下就会有一个jar包

[root@linuxea-48 /data/java-helo-word/linuxea]# ll target/hello-world-0.0.6.jar
-rw-r--r-- 1 root root 17300624 Jun 26 01:00 target/hello-world-0.0.6.jar

而后这个jar可以进行启动的,并监听了一个8086的端口号

[root@linuxea-48 /data/java-helo-word/linuxea]# java -jar target/hello-world-0.0.6.jar 

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v1.5.10.RELEASE)

2022-06-26 01:05:52.217  INFO 38183 --- [           main] com.dt.info.InfoSiteServiceApplication   : Starting InfoSiteServiceApplication v0.0.6 on Node172_16_100_48.marksugar.me with PID 38183 (/data/java-helo-word/linuxea/target/hello-world-0.0.6.jar started by root in /data/java-helo-word/linuxea)
2022-06-26 01:05:52.219  INFO 38183 --- [           main] com.dt.info.InfoSiteServiceApplication   : No active profile set, falling back to default profiles: default
2022-06-26 01:05:52.265  INFO 38183 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@48533e64: startup date [Sun Jun 26 01:05:52 CST 2022]; root of context hierarchy
2022-06-26 01:05:53.118  INFO 38183 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8086 (http)
2022-06-26 01:05:53.126  INFO 38183 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-06-26 01:05:53.129  INFO 38183 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.27
2022-06-26 01:05:53.180  INFO 38183 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-06-26 01:05:53.180  INFO 38183 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 916 ms
2022-06-26 01:05:53.256  INFO 38183 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2022-06-26 01:05:53.257  INFO 38183 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2022-06-26 01:05:53.258  INFO 38183 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2022-06-26 01:05:53.258  INFO 38183 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2022-06-26 01:05:53.258  INFO 38183 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2022-06-26 01:05:53.283  INFO 38183 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 
2022-06-26 01:05:53.287  INFO 38183 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService  'getThreadPoolTaskScheduler'
2022-06-26 01:05:53.459  INFO 38183 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@48533e64: startup date [Sun Jun 26 01:05:52 CST 2022]; root of context hierarchy
2022-06-26 01:05:53.502  INFO 38183 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/index]}" onto public java.lang.String com.dt.info.controller.HelloController.hello()
2022-06-26 01:05:53.505  INFO 38183 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2022-06-26 01:05:53.505  INFO 38183 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2022-06-26 01:05:53.529  INFO 38183 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2022-06-26 01:05:53.529  INFO 38183 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2022-06-26 01:05:53.551  INFO 38183 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2022-06-26 01:05:53.568  INFO 38183 --- [           main] oConfiguration$WelcomePageHandlerMapping : Adding welcome page: class path resource [static/index.html]
2022-06-26 01:05:53.639  INFO 38183 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2022-06-26 01:05:53.680  INFO 38183 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8086 (http)
2022-06-26 01:05:53.682  INFO 38183 --- [           main] com.dt.info.InfoSiteServiceApplication   : Started InfoSiteServiceApplication in 2.392 seconds (JVM running for 2.647)

访问

image-20220626010715129.png

现在jar包和nexus3准备好了

4.3 编写Dockerfile

当这一切准备妥当,开始编写Dockerfile,我们需要注意以下其他配置

  • 配置内存限制资源
  • 配置普通用户,并已普通用户启动pod应用程序

如下

FROM registry.cn-hangzhou.aliyuncs.com/marksugar/jdk:8u202
MAINTAINER www.linuxea.com by mark

ENV JAVA_OPTS="\
    -server \
    -Xms2048m \
    -Xmx2048m \
    -Xmn512m \
    -Xss256k \
    -XX:+UseConcMarkSweepGC \
    -XX:+UseCMSInitiatingOccupancyOnly \
    -XX:CMSInitiatingOccupancyFraction=70 \
    -XX:+HeapDumpOnOutOfMemoryError \
    -XX:HeapDumpPath=/data/logs" \
    MY_USER=linuxea \
    MY_USER_ID=316


RUN addgroup -g ${MY_USER_ID} -S ${MY_USER} \
    && adduser -u ${MY_USER_ID} -S -H -s /sbin/nologin -g 'java' -G ${MY_USER} ${MY_USER} \
    && mkdir /data/logs -p
COPY target/*.jar /data/
WORKDIR /data
USER linuxea
CMD java ${JAVA_OPTS} -jar *.jar

开始构建

我们指定配置文件位置进行创建

docker build -t hello-java -f ./Dockerfile  .

如下

[root@linuxea-48 /data/java-helo-word/linuxea]# docker build -t hello-java -f ./Dockerfile  .
Sending build context to Docker daemon   17.5MB
Step 1/7 : FROM registry.cn-hangzhou.aliyuncs.com/marksugar/jdk:8u202
 ---> 5919494d49c0
Step 2/7 : MAINTAINER www.linuxea.com by mark
 ---> Running in 51ea254cd0c3
Removing intermediate container 51ea254cd0c3
 ---> 109317878a94
Step 3/7 : ENV JAVA_OPTS="    -server     -Xms2048m     -Xmx2048m     -Xmn512m     -Xss256k     -XX:+UseConcMarkSweepGC     -XX:+UseCMSInitiatingOccupancyOnly     -XX:CMSInitiatingOccupancyFraction=70     -XX:+HeapDumpOnOutOfMemoryError     -XX:HeapDumpPath=/data/logs"     MY_USER=linuxea     MY_USER_ID=316
 ---> Running in 5745dbc7928b
Removing intermediate container 5745dbc7928b
 ---> a7d40e22389a
Step 4/7 : RUN addgroup -g ${MY_USER_ID} -S ${MY_USER}     && adduser -u ${MY_USER_ID} -S -H -s /sbin/nologin -g 'java' -G ${MY_USER} ${MY_USER}     && mkdir /data/logs -p
 ---> Running in 2e4c34e11b62
Removing intermediate container 2e4c34e11b62
 ---> d2fdac4de2fa
Step 5/7 : COPY target/*.jar /data/
 ---> 5538b183318b
Step 6/7 : WORKDIR /data
 ---> Running in 7d0ac5b1dcc2
Removing intermediate container 7d0ac5b1dcc2
 ---> e03a5699e97c
Step 7/7 : CMD java ${JAVA_OPTS} jar *.jar
 ---> Running in 58ff0459e4d7
Removing intermediate container 58ff0459e4d7
 ---> d1689a9a179f
Successfully built d1689a9a179f
Successfully tagged hello-java:latest

接着我们run起来

[root@linuxea-48 /data/java-helo-word/linuxea]# docker run --rm  hello-java  

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v1.5.10.RELEASE)

2022-06-25 17:26:22.052  INFO 1 --- [           main] com.dt.info.InfoSiteServiceApplication   : Starting InfoSiteServiceApplication v0.0.6 on f18e65565a19 with PID 1 (/data/hello-world-0.0.6.jar started by linuxea in /data)
2022-06-25 17:26:22.054  INFO 1 --- [           main] com.dt.info.InfoSiteServiceApplication   : No active profile set, falling back to default profiles: default
2022-06-25 17:26:22.121  INFO 1 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@48533e64: startup date [Sat Jun 25 17:26:22 GMT 2022]; root of context hierarchy
2022-06-25 17:26:23.079  INFO 1 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8086 (http)
2022-06-25 17:26:23.087  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-06-25 17:26:23.089  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.27
2022-06-25 17:26:23.148  INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-06-25 17:26:23.149  INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1028 ms
2022-06-25 17:26:23.236  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2022-06-25 17:26:23.240  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2022-06-25 17:26:23.240  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2022-06-25 17:26:23.240  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2022-06-25 17:26:23.240  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2022-06-25 17:26:23.273  INFO 1 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 
2022-06-25 17:26:23.279  INFO 1 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService  'getThreadPoolTaskScheduler'
2022-06-25 17:26:23.459  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@48533e64: startup date [Sat Jun 25 17:26:22 GMT 2022]; root of context hierarchy
2022-06-25 17:26:23.508  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/index]}" onto public java.lang.String com.dt.info.controller.HelloController.hello()
2022-06-25 17:26:23.511  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2022-06-25 17:26:23.511  INFO 1 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2022-06-25 17:26:23.534  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2022-06-25 17:26:23.534  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2022-06-25 17:26:23.559  INFO 1 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2022-06-25 17:26:23.654  INFO 1 --- [           main] oConfiguration$WelcomePageHandlerMapping : Adding welcome page: class path resource [static/index.html]
2022-06-25 17:26:23.786  INFO 1 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2022-06-25 17:26:23.841  INFO 1 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8086 (http)
2022-06-25 17:26:23.845  INFO 1 --- [           main] com.dt.info.InfoSiteServiceApplication   : Started InfoSiteServiceApplication in 2.076 seconds (JVM running for 2.329)

进入容器可以看到当前使用的是linuxea用户

bash-5.1$ ps aux
PID   USER     TIME  COMMAND
    1 linuxea   0:00 bash
   15 linuxea   0:00 ps aux

4.4 推送仓库

将构建的镜像推送到仓库,以备用途,于是,我们登录harbor创建一个项目存放

image-20220626014104346.png

修改镜像名称并push

docker tag hello-java harbor.marksugar.com/linuxea/hello-world:latest
docker push harbor.marksugar.com/linuxea/hello-world:latest

如下

[root@linuxea-48 /data/java-helo-word/linuxea]# docker tag hello-java harbor.marksugar.com/linuxea/hello-world:latest
[root@linuxea-48 /data/java-helo-word/linuxea]# docker push harbor.marksugar.com/linuxea/hello-world:latest
The push refers to repository [harbor.marksugar.com/linuxea/hello-world]
9435dbe70451: Pushed 
8c3c8b0adf90: Pushed 
788766eb7d3e: Mounted from base/jdk 
8d3ac3489996: Mounted from base/jdk 
latest: digest: sha256:2248bf99e35cf864d521441d8d2efc9aedbed56c24625e4f60e93df5e8fc65c3 size: 1161

此时harbor仓库已经有了已经已经打包完成的镜像,也就是所谓的一个制品

image-20220626014437853.png

0

评论

博主关闭了当前页面的评论