Skip to content

Instantly share code, notes, and snippets.

@frknbasaran
Last active July 26, 2020 00:56
Show Gist options
  • Save frknbasaran/604d131b4669480d38c7576629e6210a to your computer and use it in GitHub Desktop.
Save frknbasaran/604d131b4669480d38c7576629e6210a to your computer and use it in GitHub Desktop.
create your own docker registry on ubuntu 18.04 (tested especially on digitalocean)
#
# This script will make it easier your private docker registry
# build process on Ubuntu 18.04.
# It may require press enter during works.
#
# I recommend to run this script on initial server setup
# that contain Ubuntu 18.04.
#
# Created by Furkan Basaran <github.com/@frknbasaran>
# at 26.07.2020
#
# Do not forget to replace "registry.pengudb.com" with your own domain.
#
# Sample usage:
# ./registry-builder.sh your-registry-username
#
# update package sources for apt
sudo apt update
# install docker
sudo apt install docker.io
# install docker compose via curl
# version 1.21.2
sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
# set permissions for executable
sudo chmod +x /usr/local/bin/docker-compose
# install nginx
sudo apt install nginx
# set firewall whitelist for nginx (ufw - digitalocean)
sudo ufw allow 'Nginx HTTP'
# make nginx configurations
wget https://gist.githubusercontent.com/frknbasaran/9afaeaaa161324b3027b7ff3e1186e2d/raw/3661bc6c3191c1288d24b8c0ad452769493322f5/registry.pengudb.com
sudo mv registry.pengudb.com /etc/nginx/sites-available/registry.pengudb.com
sudo ln -s /etc/nginx/sites-available/registry.pengudb.com /etc/nginx/sites-enabled/
wget https://gist.githubusercontent.com/frknbasaran/8c1a32731e70648a8ac3fa267a958c0c/raw/7466230080ae08ef1e157061c5609d938cd1c9dd/nginx.conf
mv nginx.conf /etc/nginx/nginx.conf
# set up apache2 authentication
mkdir /root/docker-registry
sudo apt install apache2-utils
sudo mkdir ~/docker-registry/auth && cd $_
htpasswd -Bc registry.password $1
# get docker-compose yaml file for registry
cd /root/docker-registry
wget https://gist.githubusercontent.com/frknbasaran/3a02472e703f7a8684c5f010563041e7/raw/01f12a8fa841279d432aa407b70882e1c4a3496b/docker-compose.yml
# restart nginx
nginx -s reload
# run
docker-compose up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment