コンテンツにスキップ

Harbor

インストールする

1
2
$ wget https://github.com/goharbor/harbor/releases/download/v2.14.0/harbor-offline-installer-v2.14.0.tgz
$ tar xzvf harbor-offline-installer-v2.14.0.tgz

harbor.yml.tmplをベースにharbor.ymlを作成する。

httpsは全体をコメントアウトする。

data_volumeに絶対パスでボリュームを設定する。

harbor.yml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Configuration file of Harbor

# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: xxx.xxx.xxx.xxx

# http related config
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 8100

# https related config
# https:
#   # https port for harbor, default is 443
#   port: 4430
#   # The path of cert and key files for nginx
#   certificate: /absolute/path/to/server.crt
#   private_key: /absolute/path/to/server.key
#   # enable strong ssl ciphers (default: false)
#   # strong_ssl_ciphers: false

# 略

# The default data volume
data_volume: /absolute/path/to/harbor/data

以下のコマンドでコンテナを起動する。

1
2
$ cd harbor/
$ sudo ./install.sh

ユーザー名admin、パスワードHarbor12345でログインしたあと、ユーザーを作成する。

プロジェクトを作成する。

クライアント側の設定を行う

クライアント側で以下の設定を行う。

/etc/docker/daemon.json
1
2
3
{
  "insecure-registries": ["xxx.xxx.xxx.xxx:xxxx"]
}

以下のコマンドを実行し、Docker を再起動する。

1
$ sudo systemctl restart docker.service docker.socket

以下の流れでイメージを push する。

エンドポイントはIPアドレス/プロジェクト名になる。

1
2
3
4
echo $HARBOR_PASSWORD | docker login $HARBOR_ENDPOINT -u $HARBOR_USERNAME --password-stdin
docker build -t $IMAGE_NAME:$TAG_NAME .
docker tag $IMAGE_NAME:$TAG_NAME $HARBOR_ENDPOINT/$IMAGE_NAME:$TAG_NAME
docker push $HARBOR_ENDPOINT/$IMAGE_NAME:$TAG_NAME

トラブルシューティング

コンテナが自動起動しない

1
$ sudo chmod -R 755 harbor