
เตาะแตะไปกับ Docker ตอนที่ 6 Harbor (an enterprise-class registry server)
จากตอนที่แล้ว เราสามารถทำ Docker registry แบบง่าย ๆ โดยใช้ basic authentication (htpasswd) สำหรับในตอนนี้ เราจะมาทำ Harbor ซึ่งเป็น docker registry ที่มีผู้พัฒนาให้เราสร้างได้ง่ายมากขึ้น และเพิ่มขีดความสามารถให้เราเชื่อมต่อ LDAP/AD เพื่อทำ user authentication และอื่น ๆ อีกมาก ผมทดสอบกับ ubuntu server เวอร์ชั่น 16.04 สมมติว่า เราจดชื่อ FQDN ไว้คือ docker-registry.in.psu.ac.th ให้แก้ไข hostname ให้ถูกต้อง ดังนี้ $ sudo vi /etc/hostname docker-registry.in.psu.ac.th สั่งรีบูตเครื่อง $ sudo reboot ติดตั้ง ssl certificate เนื่องจากเรายังไม่ได้ใช้ certificate ที่ซื้อมา เราจะใช้ ssl-cert-snakeoil ไปก่อนก็ได้ $ sudo apt install ssl-cert ก่อนจะทำในขั้นตอนต่อไป ขณะนี้ได้ติดตั้ง docker ไว้แล้ว วิธีติดตั้งดูจากเรื่อง เตาะแตะไปกับ Docker ตอนที่ 1 Containers (Build, Ship and Run) หลังจากติดตั้ง docker แล้ว ในการติดตั้ง harbor จะต้องติดตั้ง docker-compose เพิ่ม ทำดังนี้ $ sudo apt install docker-compose ติดตั้ง harbor $ wget https://github.com/vmware/harbor/releases/download/v1.1.2/harbor-offline-installer-v1.1.2.tgz $ tar xvf harbor-offline-installer-v1.1.2.tgz $ cd harbor/ แก้ไขค่า hostname, ui_url_protocol และ ssl_cert ดังนี้ $ vi harbor.cfg #set hostname hostname = docker-registry.in.psu.ac.th #set ui_url_protocol ui_url_protocol = https …… #The path of cert and key files for nginx, they are applied only the protocol is set to https ssl_cert = /etc/ssl/certs/ssl-cert-snakeoil.pem ssl_cert_key = /etc/ssl/private/ssl-cert-snakeoil.key ทำการติดตั้ง sudo ./install.sh เข้า web browser ไปยัง https://docker-registry.in.psu.ac.th login เข้าเป็น username admin ในครั้งแรกจะได้รหัสผ่านคือ Harbor12345 แล้วตั้งค่า configuration ตัวอย่างเช่น Authentication ด้วย OpenLDAP แบบ Anonymous Bind ที่เครื่อง ldap server IP คือ 10.168.16.18 ดังนี้ เข้าเมนูตามลำดับดังนี้ Administration > Configuration > Authentication ใส่ข้อมูลเฉพาะช่องที่แนะนำ Auth Mode: LDAP LDAP URL*: ldaps://10.168.16.18 LDAP Base DN*: dc=example,dc=com LDAP UID*: