Registry | Harbor에 대하여 | Harbor port 변경 | Part 2

양승현·2023년 10월 15일
2

OpenSource

목록 보기
6/10
post-thumbnail

Harbor port 변경하기

Harbor port 변경하기

  • Harbor가 설치되어 있는 디렉터리로 이동
$ cd /offline/harbor

$ [yang@yang harbor]$ ls
certs  common  common.sh  docker-compose  docker-compose.yml  harbor.v2.8.0.tar.gz  harbor.yml  install.sh  LICENSE  prepare

$ [yang@yang harbor]$ pwd
/offline/harbor

방법1

  • Harbor.yml 수정
$ vi harbor.yml

# https related config
https:
  # https port for harbor, default is 443
  port: 444     ------------> 443에서 444로 변경
  # The path of cert and key files for nginx
  certificate: /etc/docker/certs.d/192.168.60.239:444/harbor.cert   ---------> ip 뒤 포트 또한 443에서 444로 변경하며 nginx에서 인증서 위치를 찾게하기 위해서 디렉터리 또한 192.169.60.239:444로 생성 후 이전 443에 있는 인증서를 444 디렉터리로 이동시켜줘야한다.
  private_key: /etc/docker/certs.d/192.168.60.239:444/harbor.key    ---------> ip 뒤 포트 또한 443에서 444로 변경하며 nginx에서 인증서 위치를 찾게하기 위해서 키 값 디렉터리 또한 192.169.60.239:444로 생성 후 이전 인증서를 444 디렉터리로 이동시켜줘야한다.
  • harbor 설치
$ ./install

## 만약 하버 컨테이너가 동작 중이라면 먼저 컨테이너를 중지시키고 ./install을 해야한다.
##$ docker-compose down
  • port 변경 확인
$ sudo ./docker-compose ps
      Name                     Command               State                                      Ports
-----------------------------------------------------------------------------------------------------------------------------------------
harbor-core         /harbor/entrypoint.sh            Up
harbor-db           /docker-entrypoint.sh  13        Up
harbor-jobservice   /harbor/entrypoint.sh            Up
harbor-log          /bin/sh -c /usr/local/bin/ ...   Up      127.0.0.1:1514->10514/tcp
harbor-portal       nginx -g daemon off;             Up
nginx               nginx -g daemon off;             Up      0.0.0.0:80->8080/tcp,:::80->8080/tcp, 0.0.0.0:444->8443/tcp,:::444->8443/tcp
redis               redis-server /etc/redis.conf     Up
registry            /home/harbor/entrypoint.sh       Up
registryctl         /home/harbor/start.sh            Up

방법2

  • 만약 하버 컨테이너가 동작 중이라면 먼저 컨테이너를 중지시키기
$ docker-compose down
  • nginx-proxy의 ports를 원하는 포트로 변경
# sudo vi docker-compose.yml
    242     ports:
    243       - 80:8080
    244       - 444:8443
  • 하버 배포
$ docker-compose up -d
  • port 변경 확인
$ sudo ./docker-compose ps
      Name                     Command               State                                      Ports
-----------------------------------------------------------------------------------------------------------------------------------------
harbor-core         /harbor/entrypoint.sh            Up
harbor-db           /docker-entrypoint.sh  13        Up
harbor-jobservice   /harbor/entrypoint.sh            Up
harbor-log          /bin/sh -c /usr/local/bin/ ...   Up      127.0.0.1:1514->10514/tcp
harbor-portal       nginx -g daemon off;             Up
nginx               nginx -g daemon off;             Up      0.0.0.0:80->8080/tcp,:::80->8080/tcp, 0.0.0.0:444->8443/tcp,:::444->8443/tcp
redis               redis-server /etc/redis.conf     Up
registry            /home/harbor/entrypoint.sh       Up
registryctl         /home/harbor/start.sh            Up

  • docker 인증서가 위치한 디렉토리 생성 및 인증서 이동
# 인증서가 존재하는 위치로 이동
$ cd /etc/docker/cert.s/
$ ls
192.168.60.239:443

$ mkdir -p /etc/docker/cert.s/192.168.60.239:444

# mv /etc/docker/cert.s/[harvor domain:443]/* /etc/docker/cert.s/[harbor domain:변경 포트]/ 
$ mv /etc/docker/cert.s/192.168.60.239:443/* /etc/docker/cert.s/192.168.60.239:444/
  • docker login
# 이전에 도커 로그인을 했을시 로그아웃 후 재 로그인 진행
# docker logout

# docker login -u admin -p [password] [harbor ip:port]
$ docker login -u damin -p ******* 192.168.60.239:444

WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /home/yang/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
  • harbor에 이미지 push & pull 하기
# 현재 이미지 확인
$ docker images
REPOSITORY                              TAG       IMAGE ID       CREATED        SIZE
ubuntu                                  22.04     3565a89d9e81   2 weeks ago    77.8MB

# 이미지 tag 생성
$ docker tag 3565a89d9e81 192.168.60.239:444/yang/ubuntu:soo
ubuntu                                  22.04     3565a89d9e81   2 weeks ago    77.8MB
192.168.60.239:444/yang/ubuntu          soo       3565a89d9e81   2 weeks ago    77.8MB

# harbor에 이미지 push하기
$ docker push 192.168.60.239:444/yang/ubuntu:soo
The push refers to repository [192.168.60.239:444/yang/ubuntu]
01d4e4b4f381: Layer already exists
soo: digest: sha256:4ef24535d5169dd0c12c7cbd1c751448b51d33d9afeba7b87ab60c8b1ce080e1 size: 529

# 이미지 pull 하기
$ docker pull 192.168.60.239:444/yang/ubuntu:soo
soo: Pulling from yang/ubuntu
Digest: sha256:4ef24535d5169dd0c12c7cbd1c751448b51d33d9afeba7b87ab60c8b1ce080e1
Status: Image is up to date for 192.168.60.239:444/yang/ubuntu:soo
  • 이미지를 pull하거나 push할때 변경한 포트 번호를 붙여주어야한다.
  • harbor 접속 url https:192.168.60.239:444

1개의 댓글

comment-user-thumbnail
2023년 10월 22일

블로그 잘보고 갑니다~

답글 달기