Skip to content

Instantly share code, notes, and snippets.



Forked from kacole2/
Last active Jan 18, 2021
What would you like to do?
Quick Start Harbor Installation Script on Ubuntu 18.04
#Harbor on Ubuntu 18.04
#Prompt for the user to ask if the install should use the IP Address or Fully Qualified Domain Name of the Harbor Server
PS3='Would you like to install Harbor based on IP or FQDN? '
select option in IP FQDN
case $option in
IPorFQDN=$(hostname -I|cut -d" " -f 1)
IPorFQDN=$(hostname -f)
# Housekeeping
apt update -y
swapoff --all
sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab
ufw disable #Do Not Do This In Production
echo "Housekeeping done"
#Install Latest Stable Docker Release
apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL | sudo apt-key add -
add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"
apt-get update -y
apt-get install -y docker-ce docker-ce-cli
tee /etc/docker/daemon.json >/dev/null <<EOF
"exec-opts": ["native.cgroupdriver=systemd"],
"insecure-registries" : ["$IPorFQDN:443","$IPorFQDN:80",""],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
"storage-driver": "overlay2"
mkdir -p /etc/systemd/system/docker.service.d
groupadd docker
usermod -aG docker $MAINUSER
systemctl daemon-reload
systemctl restart docker
echo "Docker Installation done"
#Install Latest Stable Docker Compose Release
COMPOSEVERSION=$(curl -s 2>&1 | grep -Po [0-9]+\.[0-9]+\.[0-9]+)
curl -L "$COMPOSEVERSION/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
echo "Docker Compose Installation done"
#Install Latest Stable Harbor Release
HARBORVERSION=$(curl -s 2>&1 | grep -Po [0-9]+\.[0-9]+\.[0-9]+)
curl -s | grep browser_download_url | grep online | cut -d '"' -f 4 | wget -qi -
tar xvf harbor-online-installer-v$HARBORVERSION.tgz
cd harbor
cp harbor.yml.tmpl harbor.yml
sed -i "s/$IPorFQDN/g" harbor.yml
sed -e '/port: 443$/ s/^#*/#/' -i harbor.yml
sed -e '/https:$/ s/^#*/#/' -i harbor.yml
sed -e '/\/your\/certificate\/path$/ s/^#*/#/' -i harbor.yml
sed -e '/\/your\/private\/key\/path$/ s/^#*/#/' -i harbor.yml
./ --with-clair --with-chartmuseum
echo -e "Harbor Installation Complete \n\nPlease log out and log in or run the command 'newgrp docker' to use Docker without sudo\n\nLogin to your harbor instance:\n docker login -u admin -p Harbor12345 $IPorFQDN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment