vSphere Integrated Containers (VIC) 1.0 には、Harbor という Container Registry が含まれています。
Harbor は、GitHub で公開されています。
今回は、インストレーション ガイドを参考に、Harbor をセットアップしてみます。
harbor/installation_guide.md at master · vmware/harbor · GitHub
Harbor のセットアップには、3通りのセットアップ方法があります。
- Online installer ※Harbor のコンテナイメージをインターネットからダウンロードする。
- Offline installer ※インストール対象のサーバがインターネット接続できない場合はこれ。
- Virtual Appliance ※OVA をデプロイ。
今回は、Harbor のソフトウェア構成が分かりやすい Online installer を使用しています。
ただし、VIC の製品サポートが必要な場合は、
MyVMware からダウンロードした OVA を使用することになります。
今回の構成。
Harbor と Docker Host の2台の VM を、VMware Workstation 12 にデプロイします。
ただし、Harbor のサーバでも Docker Engine が起動するので 1台 だけでも大丈夫です。
Harbor は、VIC 1.0 に含まれるバージョンと同じ、
Harbor 0.5 を GitHub からダウンロードして使用します。
Harbor と、そこにアクセスする Docker Host の OS は、どちらも Photon OS 1.0 を使用しています。
下記にある「OVA with virtual hardware v11」を使用しています。
Downloading Photon OS · vmware/photon Wiki · GitHub
Docker 環境の準備。
まず、Harbor と Docker Host 両方で Docker Engine を設定します。
Photon の OVA ファイルを 2つデプロイします・・・
デプロイした Photon を起動して、root/changeme ログインして初期パスワード変更をします。
ホスト名はわかりやすいものに変更しておきます。
今回は、下記のホスト名にしています。
- Harbor: harbor01
- Docker Host: photon01
ホスト名を設定し、OS にログインしなおすか、OS を再起動すると
プロンプトにホスト名が反映されます。
Harbor サーバ
# hostnamectl set-hostname harbor01
Docker Host
# hostnamectl set-hostname photon01
IP アドレスとホスト名を /etc/hosts ファイルに追記しておきます。
※Harbor と Docker Host 両方で設定します。
※今回の Harbor の IP アドレスは 192.168.254.130 です。
# echo "192.168.254.130 harbor01" >> /etc/hosts
tdnf コマンドで RPM をアップグレードしておきます。
# tdnf upgrade -y
OS を再起動します。
# reboot
アップグレード後の環境です。
root@harbor01 [ ~ ]# cat /etc/photon-release
VMware Photon Linux 1.0
PHOTON_BUILD_NUMBER=62c543d
root@harbor01 [ ~ ]# uname -a
Linux harbor01 4.4.41-1.ph1-esx #1-photon SMP Tue Jan 10 23:46:44 UTC 2017 x86_64 GNU/Linux
root@harbor01 [ ~ ]# rpm -q docker
docker-1.12.1-1.ph1.x86_64
docker サービスを起動します。
root@harbor01 [ ~ ]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
root@harbor01 [ ~ ]# systemctl start docker
root@harbor01 [ ~ ]# docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 1.12.1
Storage Driver: overlay
Backing Filesystem: extfs
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: host bridge overlay null
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.4.41-1.ph1-esx
Operating System: VMware Photon/Linux
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.958 GiB
Name: harbor01
ID: E3H3:PD22:G5DK:RMMJ:NJ2Z:EXJJ:MPZO:4A6D:2YBX:FWNW:GWXO:FR2K
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Insecure Registries:
127.0.0.0/8
Harbor サーバへの docker-compose インストール。
Harbor を構成するコンテナ群は、docker-compose で起動/停止するので、
下記を参考に、docker-compose をインストールします。
Install Docker Compose - Docker
docker-compose ファイルをダウンロードして、chmod コマンドで実行権限を付与します。
root@harbor01 [ ~ ]# curl -L "https://github.com/docker/compose/releases/download/1.9.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
root@harbor01 [ ~ ]# chmod +x /usr/local/bin/docker-compose
ファイルが実行できるようになったことを確認しておきます。
root@harbor01 [ ~ ]# docker-compose --version
docker-compose version 1.9.0, build 2585387
Harbor サーバへの tar インストール。
デフォルトでは Photon OS に tar コマンドがインストールされていません。
Harbor のインストーラを展開するために tdnf でインストールしておきます。
root@harbor01 [ ~ ]# tdnf install -y tar
Harbor のインストール。
まず、「harbor-online-installer-0.5.0.tgz」を GitHub からダウンロードします。
root@harbor01 [ ~ ]# curl -L https://github.com/vmware/harbor/releases/download/0.5.0/harbor-online-installer-0.5.0.tgz -o harbor-online-installer-0.5.0.tgz
root@harbor01 [ ~ ]# tar zxf harbor-online-installer-0.5.0.tgz
root@harbor01 [ ~ ]# ls -lh harbor
total 248K
-rw-r--r-- 1 root root 212K Dec 6 08:58 LICENSE
-rw-r--r-- 1 root root 483 Dec 6 08:58 NOTICE
drwxr-xr-x 3 root root 4.0K Dec 6 08:58 common
-rw-r--r-- 1 root root 2.2K Dec 6 08:58 docker-compose.yml
-rw-r--r-- 1 root root 3.7K Dec 6 08:58 harbor.cfg
-rwxr-xr-x 1 root root 4.4K Dec 6 08:58 install.sh
-rwxr-xr-x 1 root root 12K Dec 6 08:58 prepare
harbor.cfg を編集します。
今回は Harbor に HTTP で接続するので、hostname だけ編集します。
デフォルトでは下記のようになっています。
root@harbor01 [ ~ ]# cd harbor/
root@photon01 [ ~/harbor ]# grep ^hostname harbor.cfg
hostname = reg.mydomain.com
ちなみに、admin ユーザのデフォルト パスワードもこのファイルで指定します。
root@harbor01 [ ~/harbor ]# grep harbor_admin_password harbor.cfg
harbor_admin_password = Harbor12345
hostname を Harbor サーバのアドレスに修正します。
root@harbor01 [ ~/harbor ]# vi harbor.cfg
root@harbor01 [ ~/harbor ]# grep ^hostname harbor.cfg
hostname = 192.168.254.130
install.sh を実行して、インストールします。
Harbor のコンテナイメージが Docker Hub からダウンロードされ、docker-compose で起動されます。
root@harbor01 [ ~/harbor ]# ./install.sh
[Step 0]: checking installation environment ...
Note: docker version: 1.12.1
Note: docker-compose version: 1.9.0
[Step 1]: preparing environment ...
generated and saved secret key
Generated configuration file: ./common/config/nginx/nginx.conf
Generated configuration file: ./common/config/ui/env
Generated configuration file: ./common/config/ui/app.conf
Generated configuration file: ./common/config/registry/config.yml
Generated configuration file: ./common/config/db/env
Generated configuration file: ./common/config/jobservice/env
Generated configuration file: ./common/config/jobservice/app.conf
Generated configuration file: ./common/config/ui/private_key.pem
Generated configuration file: ./common/config/registry/root.crt
The configuration files are ready, please use docker-compose to start the service.
[Step 2]: checking existing instance of Harbor ...
[Step 3]: starting Harbor ...
Creating network "harbor_default" with the default driver
Pulling log (vmware/harbor-log:0.5.0)...
0.5.0: Pulling from vmware/harbor-log
93b3dcee11d6: Pull complete
5c14e4bdfb0b: Pull complete
e4dee8a574ca: Pull complete
64897311fadc: Pull complete
9b18f82d0181: Pull complete
Digest: sha256:81db268fa32ed35274f88f0e9f6e8c8fe36fdfe3247a7c75cef3d526814755ad
Status: Downloaded newer image for vmware/harbor-log:0.5.0
Pulling ui (vmware/harbor-ui:0.5.0)...
0.5.0: Pulling from vmware/harbor-ui
93b3dcee11d6: Already exists
a91de92f52f5: Pull complete
341612b46e3b: Pull complete
c1a53f812656: Pull complete
9a9aa413559a: Pull complete
e1b377650dfc: Pull complete
be5517028022: Pull complete
726f4e0b4799: Pull complete
08639f4ec97a: Pull complete
Digest: sha256:677776af19c774f665565486ef0ec3ab37e55c6738a471942e3ea841b3e1821c
Status: Downloaded newer image for vmware/harbor-ui:0.5.0
Pulling mysql (vmware/harbor-db:0.5.0)...
0.5.0: Pulling from vmware/harbor-db
43c265008fae: Pull complete
d7abd54d3b34: Pull complete
92b527830a1b: Pull complete
44839710d611: Pull complete
3828a16bed5c: Pull complete
fb91763f6b4e: Pull complete
892bfb27c685: Pull complete
02874ec7a2dc: Pull complete
861c1296cc0d: Pull complete
d611998d5598: Pull complete
09037dc5a941: Pull complete
448973dd2180: Pull complete
c0a51ede01de: Pull complete
54c4b53ba168: Pull complete
Digest: sha256:4bc45566b8aab9288e76ac8a36e604aecf05ba9b25e22f5a9cd5e9686978b78b
Status: Downloaded newer image for vmware/harbor-db:0.5.0
Pulling jobservice (vmware/harbor-jobservice:0.5.0)...
0.5.0: Pulling from vmware/harbor-jobservice
93b3dcee11d6: Already exists
a91de92f52f5: Already exists
cdeb4de41efe: Pull complete
ce3594a70659: Pull complete
Digest: sha256:9c2d927f6e59fafcc930a5f738d713bde7d101cecd4e110a570a7b499d69ff68
Status: Downloaded newer image for vmware/harbor-jobservice:0.5.0
Pulling registry (library/registry:2.5.0)...
2.5.0: Pulling from library/registry
e110a4a17941: Pull complete
2ee5ed28ffa7: Pull complete
d1562c23a8aa: Pull complete
06ba8e23299f: Pull complete
802d2a9c64e8: Pull complete
Digest: sha256:1b68f0d54837c356e353efb04472bc0c9a60ae1c8178c9ce076b01d2930bcc5d
Status: Downloaded newer image for registry:2.5.0
Pulling proxy (nginx:1.11.5)...
1.11.5: Pulling from library/nginx
386a066cd84a: Pull complete
7bdb4b002d7f: Pull complete
49b006ddea70: Pull complete
Digest: sha256:9038d5645fa5fcca445d12e1b8979c87f46ca42cfb17beb1e5e093785991a639
Status: Downloaded newer image for nginx:1.11.5
Creating harbor-log
Creating harbor-db
Creating harbor-ui
Creating registry
Creating harbor-jobservice
Creating nginx
? ----Harbor has been installed and started successfully.----
Now you should be able to visit the admin portal at http://192.168.254.130.
For more details, please visit https://github.com/vmware/harbor .
root@harbor01 [ ~/harbor ]#
Harbor 関連のイメージです。
root@harbor01 [ ~/harbor ]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
vmware/harbor-log 0.5.0 eebc987a891b 5 weeks ago 190.5 MB
vmware/harbor-jobservice 0.5.0 995368e96860 5 weeks ago 169.4 MB
vmware/harbor-ui 0.5.0 232a8664541a 5 weeks ago 233 MB
vmware/harbor-db 0.5.0 84c4ce8e9b6c 5 weeks ago 326.8 MB
nginx 1.11.5 05a60462f8ba 9 weeks ago 181.4 MB
registry 2.5.0 c6c14b3960bd 5 months ago 33.28 MB
Harbor を構成するコンテナ群が起動しています。
root@harbor01 [ ~/harbor ]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fd39c3b81527 nginx:1.11.5 "nginx -g 'daemon off" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp nginx
271c78450675 vmware/harbor-jobservice:0.5.0 "/harbor/harbor_jobse" About a minute ago Up About a minute harbor-jobservice
8fd149da1a89 library/registry:2.5.0 "/entrypoint.sh serve" About a minute ago Up About a minute 5000/tcp registry
ceb3f0f450dc vmware/harbor-ui:0.5.0 "/harbor/harbor_ui" About a minute ago Up About a minute harbor-ui
926e637f2f34 vmware/harbor-db:0.5.0 "docker-entrypoint.sh" About a minute ago Up About a minute 3306/tcp harbor-db
bd44e1d40ef7 vmware/harbor-log:0.5.0 "/bin/sh -c 'crond &&" About a minute ago Up About a minute 0.0.0.0:1514->514/tcp harbor-log
Harbor Registry へのプロジェクト作成。
Web ブラウザから Harbor の HTTP (TCP 80 番)ポートにアクセスします。
admin ユーザ(今回のパスワードは Harbor12345)でログインします。
Image may be NSFW.
Clik here to view.
「Projects」を開きます。
Image may be NSFW.
Clik here to view.
「New Project」をクリックします。
Image may be NSFW.
Clik here to view.
Project の名前を入力して、「Save」します。今回は「pj01」という名前にしました。
Image may be NSFW.
Clik here to view.
pj01 が作成されました。
Image may be NSFW.
Clik here to view.
まだ pj01 にコンテナ イメージはありません。
Image may be NSFW.
Clik here to view.
Docker Host からのアクセスするための準備。
Docker Host から、Harbor に接続してみます。
今回は HTTP で接続するので、docker サービスの「--insecure-registry」に
Harbor のアドレス(今回は 192.168.254.130:80)を指定しておきます。
docker.serive を編集します。
root@photon01 [ ~ ]# cp /usr/lib/systemd/system/docker.service /etc/systemd/system/
root@photon01 [ ~ ]# vi /etc/systemd/system/docker.service
/etc/systemd/system/docker.service ファイルの内容
※赤字が、追記した部分です。
[Unit]
Description=Docker Daemon
Documentation=http://docs.docker.com
Wants=network-online.target
After=network-online.target docker-containerd.service
Requires=docker-containerd.service
[Service]
Type=notify
EnvironmentFile=-/etc/default/docker
ExecStart=/usr/bin/docker daemon $DOCKER_OPTS \
--containerd /run/containerd.sock \
--insecure-registry 192.168.254.130:80
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-abnormal
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
[Install]
WantedBy=multi-user.target
docker サービスを再起動して、設定を読み込みます。
root@photon01 [ ~ ]# systemctl daemon-reload
root@photon01 [ ~ ]# systemctl restart docker
root@photon01 [ ~ ]# docker info | grep Insecure -A2
Insecure Registries:
192.168.254.130:80
127.0.0.0/8
Harbor Registry を使用してみる。
まず Dcoker Host で、Docker Hub からイメージをダウンロードします。
今回は、Docker 公式の oraclelinux イメージをダウンロードしています。
root@photon01 [ ~ ]# docker pull oraclelinux
Using default tag: latest
latest: Pulling from library/oraclelinux
2c48edfee2a0: Pull complete
Digest: sha256:d447e228f31c753842d0de64a610a0b480b6c7b850c27813a67fd8e7a938ccee
Status: Downloaded newer image for oraclelinux:latest
root@photon01 [ ~ ]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
oraclelinux latest 27a5201e554e 3 weeks ago 225.1 MB
Harbor にログインします。
今回は新規ユーザを作成していないので、admin ユーザを使用しています。
root@photon01 [ ~ ]# docker login 192.168.254.130:80
Username: admin
Password: ★パスワード入力
Login Succeeded
イメージに Harbor のアドレスと、先ほど作成したプロジェクト「pj01」を指定して
イメージに tag を追加します。
root@photon01 [ ~ ]# docker tag oraclelinux:latest 192.168.254.130:80/pj01/oraclelinux:latest
root@photon01 [ ~ ]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.254.130:80/pj01/oraclelinux latest 27a5201e554e 3 weeks ago 225.1 MB
oraclelinux latest 27a5201e554e 3 weeks ago 225.1 MB
Harbor に push します。
root@photon01 [ ~ ]# docker push 192.168.254.130:80/pj01/oraclelinux:latest
The push refers to a repository [192.168.254.130:80/pj01/oraclelinux]
89587f215a9e: Pushed
latest: digest: sha256:d447e228f31c753842d0de64a610a0b480b6c7b850c27813a67fd8e7a938ccee size: 529
Harbor の 「pj01」 Project にイメージが追加されました。
Image may be NSFW.
Clik here to view.
いったんローカルのイメージを削除してから・・・
root@photon01 [ ~ ]# docker rmi 192.168.254.130:80/pj01/oraclelinux oraclelinux
Untagged: 192.168.254.130:80/pj01/oraclelinux:latest
Untagged: 192.168.254.130:80/pj01/oraclelinux@sha256:d447e228f31c753842d0de64a610a0b480b6c7b850c27813a67fd8e7a938ccee
Untagged: oraclelinux:latest
Untagged: oraclelinux@sha256:d447e228f31c753842d0de64a610a0b480b6c7b850c27813a67fd8e7a938ccee
Deleted: sha256:27a5201e554e153245d57333ed509141512ff5c1aaf3552bc53a983a72210ef6
Deleted: sha256:89587f215a9e2692b6674efc86247e15d8cb0f04690712fbdcac63d136b95e2b
Harbor からイメージをダウンロードしてみます。
oraclelinux のイメージが Harbor からダウンロードされて、コンテナとして起動しました。
root@photon01 [ ~ ]# docker run -it 192.168.254.130:80/pj01/oraclelinux:latest /bin/bash
Unable to find image '192.168.254.130:80/pj01/oraclelinux:latest' locally
latest: Pulling from pj01/oraclelinux
2c48edfee2a0: Pull complete
Digest: sha256:d447e228f31c753842d0de64a610a0b480b6c7b850c27813a67fd8e7a938ccee
Status: Downloaded newer image for 192.168.254.130:80/pj01/oraclelinux:latest
[root@6bde61e50c8a /]# cat /etc/oracle-release
Oracle Linux Server release 7.3
このような感じで、registry イメージによるものと同様に使用することができて、
さらにアクセス制御機能などが追加されています。
VIC については、こちらもどうぞ。
vSphere Integrated Containers (VIC) 1.0 をためしてみる。
vSphere Integrated Containers Engine の vSphere Web Client Plug-In から見る Docker 情報。
以上。Harbor による Docker Registry 構築でした。
Clik here to view.