$ sudo apt update
$ sudo apt install nginx
$ sudo ufw allow 'Nginx HTTP'
$ systemctl status nginx
$ sudo mkdir -p /var/www/my-domain.host/html
$ sudo chown -R $USER:$USER /var/www/my-domain.host/html
$ sudo chmod -R 755 /var/www/my-domain.host
$ sudo nano /var/www/my-domain.host/html/index.html
<html>
<head>
<title>
Domain on Nginx
</title>
</head>
<body>
<h1>
Connection to my-domain.host is created successfully!!!
</h1>
</body>
</html>
$ sudo nano /etc/nginx/sites-available/my-domain.host
server
{
listen 80;
listen [::]:80;
root /var/www/my-domain.host/html;
index index.html index.htm index.nginx-debian.html;
server_name my-domain.host www.my-domain.host;
location /
{
try_files $uri $uri/ =404;
}
}
$ sudo ln -s /etc/nginx/sites-available/my-domain.host /etc/nginx/sites-enabled/
$ sudo nano /etc/nginx/nginx.conf
$ sudo nginx -t
$ sudo systemctl restart nginx
$ sudo apt install snapd
$ sudo snap install --classic certbot
$ sudo ln -s /snap/bin/certbot /usr/bin/certbot
$ sudo ufw allow 'Nginx Full'
$ sudo ufw delete allow 'Nginx HTTP'
$ sudo ufw status
$ sudo certbot --nginx
$ sudo apt install apt-transport-https ca-certificates curl software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
$ sudo apt update
$ apt-cache policy docker-ce
$ sudo apt install docker-ce
$ sudo systemctl status docker
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
$ docker-compose --version
$ mkdir ~/docker-registry
$ cd ~/docker-registry
$ mkdir data
$ sudo nano docker-compose.yml
version: '3'
services:
registry:
image: registry:2
ports:
- "5000:5000"
environment:
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data
volumes:
- ./data:/data
$ docker-compose up
$ sudo nano /etc/nginx/sites-available/my-domain.host
location / {
# Do not allow connections from docker 1.5 and earlier
# docker pre-1.6.0 did not properly set the user agent on ping, catch "Go *" user agents
if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go ).*$" ) {
return 404;
}
proxy_pass http://localhost:5000;
proxy_set_header Host $http_host; # required for docker client's sake
proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 900;
}
$ sudo systemctl restart nginx
$ cd ~/docker-registry
$ docker-compose up
https://my-domain.host/v2
$ sudo apt install apache2-utils
$ mkdir ~/docker-registry/auth
$ cd ~/docker-registry/auth
$ htpasswd -Bc registry.password user1
$ htpasswd -B registry.password user2
version: '3'
services:
registry:
image: registry:2
ports:
- "5000:5000"
environment:
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_REALM: Registry
REGISTRY_AUTH_HTPASSWD_PATH: /auth/registry.password
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data
volumes:
- ./auth:/auth
- ./data:/data
$ cd ~/docker-registry
$ docker-compose up
$ sudo nano ~/docker-registry/docker-compose.yml
version: '3'
services:
registry:
restart: always
image: registry:2
ports:
- "5000:5000"
environment:
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_REALM: Registry
REGISTRY_AUTH_HTPASSWD_PATH: /auth/registry.password
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data
volumes:
- ./auth:/auth
- ./data:/data
$ docker-compose up -d
$ cd /etc/nginx
$ sudo nano nginx.conf
http {
##
# Basic Settings
##
client_max_body_size 16384m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
$ sudo systemctl restart nginx
$ sudo usermod -aG docker your-user
$ docker run -t -i ubuntu /bin/bash
root@2b8dcf17a0db:/# touch /my.IMAGE
root@2b8dcf17a0db:/# exit
$ docker commit $(docker ps -lq) new-ubuntu-image
$ docker login https://my-domain.host
$ docker tag new-ubuntu-image my-domain.host/new-ubuntu-image
$ docker push my-domain.host/new-ubuntu-image
$ docker images
$ docker rmi new-ubuntu-image
$ docker rmi my-domain.host/new-ubuntu-image
$ docker images
$ docker login https://my-domain.host
$ docker pull my-domain.host/new-ubuntu-image
$ docker images
$ docker run -t -i my-domain.host/new-ubuntu-image
root@65c69421278c:/# ls -l