Docker私有仓库Harbor搭建及修改默认80端口

环境

操作系统:Centos 7

 

Harbor版本:1.7.5

服务器地址:192.168.8.216

Harbor下载地址:https://github.com/goharbor/harbor/releases

Harbor安装教程:https://www.cnblogs.com/pangguoping/p/7650014.html

 

Docker版本:18.09.5

Docker安装教程:https://www.cnblogs.com/yufeng218/p/8370670.html

 

Harbor端口修改

1、进入harbor解压后目录,编辑docker-compose.yml

# vim docker-compose.yml

2、修改proxy中的ports中对应的端口号,此处是将 80 改为 1180

proxy:
    image: goharbor/nginx-photon:v1.7.5
    container_name: nginx
    restart: always
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - SETGID
      - SETUID
      - NET_BIND_SERVICE
    volumes:
      - ./common/config/nginx:/etc/nginx:z
    networks:
      - harbor
    dns_search: .
    ports:
      - 1180:80
      - 443:443
      - 4443:4443
    depends_on:
      - postgresql
      - registry
      - core
      - portal
      - log
    logging:
      driver: "syslog"
      options:
        syslog-address: "tcp://127.0.0.1:1514"
        tag: "proxy"

3、停止harbor,重新启动并生成配置文件:

# docker-compose stop
# ./install.sh

Docker配置修改

1、修改docker.service

# vim /usr/lib/systemd/system/docker.service

ExecStart处添加 --insecure-registry=192.168.8.216:1180 ,修改后入下所示:

ExecStart=/usr/bin/dockerd --insecure-registry=192.168.8.216:1180 -H tcp://0.0.0.0:2375 -H fd:// --containerd=/run/containerd/containerd.sock

2、重启docker服务

# systemctl daemon-reload
# systemctl restart docker.service

Maven配置

修改setting.xml

 1、servers中添加如下代码: 

 

    <server>
    	<id>harbor</id>
    	<username>admin</username>
    	<password>Harbor12345</password>
    </server>

2、pluginGroups中添加如下代码:

    <pluginGroup>com.spotify</pluginGroup>

项目配置

1、配置pom.xml

    <properties>
        <docker.serverId>harbor</docker.serverId>
        <docker.registry.url>192.168.8.216:1180</docker.registry.url>
        <docker.plugin.version>1.2.0</docker.plugin.version>
    </properties>
   <build>
        <plugins>
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>${docker.plugin.version}</version>
                <configuration>
                    <imageName>${docker.registry.url}/library/${project.artifactId}:${project.version}</imageName>
                    <dockerDirectory>${project.basedir}</dockerDirectory>
                    <dockerHost>${docker.registry.host}</dockerHost>
                    <resources>
                        <resource>
                            <targetPath>/</targetPath>
                            <directory>${project.build.directory}</directory>
                            <include>${project.build.finalName}.jar</include>
                        </resource>
                    </resources>
                    <registryUrl>${docker.registry.url}</registryUrl>
                    <serverId>${docker.serverId}</serverId>
                    <pushImage>true</pushImage>
                </configuration>
            </plugin>
         
        </plugins>
    </build>

2、测试发布

# mvn clean package docker:build

 

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页