Set Up Harbor in Alpine Linux
Set up Harbor in Alpine Linux
The steps here are adapted from here.
Pre-requisites
The Alpine Linux host must have the following:
- Docker Engine
- Docker Compose
The host should also have these supporting tools already installed:
- curl
- wget
- tar
- openssl
It should also run the bash shell as the harbor scripts work better.
Create Harbor Folder
mkdir -p /opt/harborDownload and Extract Harbor
The full list of Harbor Releases can be found here.
I'm using the offline version of v2.14.4.
cd /opt
wget https://github.com/goharbor/harbor/releases/download/v2.14.4/harbor-offline-installer-v2.14.4.tgz
tar zvxf harbor-offline-installer-v2.14.4.tgzConfigure Harbor
cd /opt/harbor
cp harbor.yml.tmpl harbor.ymlPrepare certificates for harbor use. Place the .key and .crt in /etc/harbor/certs.
Edit harbor.yml. Minimally:
hostname: harbor.example.com
http:
port: 80
https:
port: 443
certificate: /etc/harbor/certs/harbor.crt
private_key: /etc/harbor/certs/harbor.key
harbor_admin_password: StrongPasswordHere
data_volume: /dataGenerate Harbor Configuration
./prepare --with-trivyInstall Harbor
./install --with-trivyVerify Containers
docker psYou should see:
harbor-core
harbor-db
harbor-portal
harbor-jobservice
harbor-log
harbor-nginx
registry
registryctl
redis
trivy-adapterAccess Harbor
Navigate to https://harbor.example.com in your favourite browser.
The default login username is: admin
The password is whatever you have configured in the steps above.
Using Docker Client
docker login harbor.example.com
docker pull hello-world:latest
docker tag hello-world:latest harbor.example.com/library/hello-world:latest
docker push harbor.example/library/hello-world:latestManaging Harbor
Start:
cd /opt/harbor
docker compose up -dStop:
cd /opt/harbor
docker compose downRestart:
cd /opt/harbor
docker compose restartView logs:
cd /opt/harbor
docker compose logs -fCreate an OpenRC Service
Create a new /etc/init.d/harbor file with the following contents:
#!/sbin/openrc-run
name="Harbor"
description="Harbor Registry"
depend() {
need docker
}
start() {
ebegin "Starting Harbor"
cd /opt/harbor
docker compose up -d
eend $?
}
stop() {
ebegin "Stopping Harbor"
cd /opt/harbor
docker compose down
eend $?
}Make executable:
chmod +x /etc/init.d/harborEnable service:
rc-update add harbor
rc-update -uStart it immediately, if you want:
rc-service harbor start