zoukankan      html  css  js  c++  java
  • maven 上传 docker 到 nexus

    nexus 安装:https://blog.csdn.net/hanjun0612/article/details/105199191

    docker destop 安装:https://blog.csdn.net/hanjun0612/article/details/119798564

    上面的就不赘述了。

    一,查看nexus 仓库

    假设这个仓库的地址:nexus/java/

    用户名:admin

    密码:admin

    二,配置maven

    maven 的settings.xml添加

    <server>   
        <id>test</id>   
        <username>admin</username>   
        <password>admin</password>   
      </server>  

    三,pom文件

    <plugin>
                        <groupId>com.spotify</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>1.2.0</version>
                        <configuration>
                            <!--nexus3 hosted 仓库地址-->
                            <registryUrl>nexus/java/</registryUrl>
                            <!--Dockerfile路径,如果你使用dockerfile,就取消注释-->
    <!--                        <dockerDirectory>src/main/docker</dockerDirectory>-->
                            <!--是否强制覆盖已有镜像-->
                            <forceTags>true</forceTags>
                            <baseImage>openjdk</baseImage>
                            <!--复制jar包到docker容器指定目录配置-->
                            <resources>
                                <resource>
                                    <targetPath>/</targetPath>
                                    <directory>${project.build.directory}</directory>
                                    <include>${project.build.finalName}.jar</include>
                                </resource>
                            </resources>
                            <!--在maven settings.xml中配置的server的id值-->
                            <serverId>test</serverId>
                        </configuration>
                    </plugin>

    dockerfile

    自行修改 ADD中的  jar包名

    FROM openjdk
    VOLUME /tmp
    ADD registry-1.0.jar app.jar
    RUN bash -c 'touch /app.jar'
    ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
    #设置时区
    RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone

    最后 maven 运行

    #login  nexusip:port  是你的nexus地址和端口
    docker login --username=admin --password="admin" nexusip:port

    #修改tag名
    #其实这里tag是对的,只是需要前缀namespace
    #因此打包前,把<imageName>设置为 docker_hosted/imageName:tag 就可以忽略这一步

    docker tag imageID nexus的docker_hosted/hello-world:1.0
    #上传
    docker push nexus的docker_hosted/hello-world:1.0
  • 相关阅读:
    Windows下好用的git客户端--GitExtentions
    高分辨率下放大netbeans中的小图标
    小书匠使用手册
    win8 telnet VirtualBox中的redhat9
    win8安装新字体
    netbeans设置字体
    win7下Chrome有两个图标的解决方法
    【转】HDU-6035-Colorful Tree
    POJ1703--Find them, Catch them(种类并查集)
    KMP的妙用(利用next数组寻找字符串的循环节)
  • 原文地址:https://www.cnblogs.com/hanjun0612/p/15162520.html
Copyright © 2011-2022 走看看