-
-
Save kacole2/95e83ac84fec950b1a70b0853d6594dc to your computer and use it in GitHub Desktop.
#!/bin/bash | |
#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 | |
do | |
case $option in | |
IP) | |
IPorFQDN=$(hostname -I|cut -d" " -f 1) | |
break;; | |
FQDN) | |
IPorFQDN=$(hostname -f) | |
break;; | |
esac | |
done | |
# 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 https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
apt-get update -y | |
apt-get install -y docker-ce docker-ce-cli containerd.io | |
tee /etc/docker/daemon.json >/dev/null <<EOF | |
{ | |
"exec-opts": ["native.cgroupdriver=systemd"], | |
"insecure-registries" : ["$IPorFQDN:443","$IPorFQDN:80","0.0.0.0/0"], | |
"log-driver": "json-file", | |
"log-opts": { | |
"max-size": "100m" | |
}, | |
"storage-driver": "overlay2" | |
} | |
EOF | |
mkdir -p /etc/systemd/system/docker.service.d | |
groupadd docker | |
MAINUSER=$(logname) | |
usermod -aG docker $MAINUSER | |
systemctl daemon-reload | |
systemctl restart docker | |
echo "Docker Installation done" | |
#Install Latest Stable Docker Compose Release | |
COMPOSEVERSION=$(curl -s https://github.com/docker/compose/releases/latest/download 2>&1 | grep -Po [0-9]+\.[0-9]+\.[0-9]+) | |
curl -L "https://github.com/docker/compose/releases/download/$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 https://github.com/goharbor/harbor/releases/latest/download 2>&1 | grep -Po [0-9]+\.[0-9]+\.[0-9]+) | |
curl -s https://api.github.com/repos/goharbor/harbor/releases/latest | grep browser_download_url | grep online | cut -d '"' -f 4 | wget -qi - | |
tar xvf harbor-online-installer-v$HARBORVERSION.tgz | |
cd harbor | |
sed -i "s/reg.mydomain.com/$IPorFQDN/g" harbor.yml | |
./install.sh --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" |
Original script + @kcalmond 's comment fixed.
https://gist.github.com/kacole2/95e83ac84fec950b1a70b0853d6594dc#gistcomment-3436546
here is the whole script fixed. working with version 2.1.0
https://gist.github.com/danielporto/86463aeb2efc816f044695847167ae2a
Hi all. This script has been abandoned because this is NOT the preferred way to install or operate Harbor. There is currently a Helm chart that takes care of the entire installation. There is also an Operator that will be released soon that will be the new successor of the Helm chart.
Might be a good idea to take it off the harbor site if it's not meant to be used? https://goharbor.io/docs/2.1.0/install-config/quick-install-script/
@kacole2 Where can we find this helm chart or the Operator?
clair has been deprecated on Debian (bullseye?), ✖ Clair is deprecated please remove it from installation arguments !!!
Maybe this cen be removed from the installation file. For the rest it works pretty sweet on Debian :-)
This doesn't work now since docker-compose
's link is updated
This doesn't work now since
docker-compose
's link is updated
Just add a v in front of $COMPOSEVERSION
curl -L "https://github.com/docker/compose/releases/download/v$COMPOSEVERSION/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
I've forked and fixed it here: https://gist.github.com/andrewd-sysdig/4d712671053e2279a643f67e265fdbb0
I also had to create /var/log/harbor
If anyone visiting this thread needs an updated and fully working installer:
https://github.com/ron7/harbor_installer
- tested on Ubuntu 18.04, 20.04 and 22.04
- can run fully unattended
- can take ENV variables
- can be run multiple times (to reapply configs)
After running the script, I have problem with
docker login
:Error response from daemon: Get http://xxx.xxx.xxx.xx/v2/: dial tcp xxx.xxx.xxx.xx:80: connect: connection refused
Anyone knows why?
were you able to solve it? I am getting the same error.
After running the script, I have problem with
docker login
:Error response from daemon: Get http://xxx.xxx.xxx.xx/v2/: dial tcp xxx.xxx.xxx.xx:80: connect: connection refused
Anyone knows why?
were you able to solve it? I am getting the same error.
You should be using https
After running the script, I have problem with
docker login
:Error response from daemon: Get http://xxx.xxx.xxx.xx/v2/: dial tcp xxx.xxx.xxx.xx:80: connect: connection refused
Anyone knows why?
were you able to solve it? I am getting the same error.
You should be using https
to use https I need to add certificate and key
damn.. is not working. :-/