guguji666666 / Docker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Install Docker Docker-compose and Nginx proxy manager on debian 11

1. Check system time and install common softwares

Check current system time

date

Modify system time

dpkg-reconfigure tzdata

Update packages

sudo su root
apt update -y
apt install wget curl sudo vim git -y

2. SWAP if required

wget -O box.sh https://raw.githubusercontent.com/BlueSkyXN/SKY-BOX/main/box.sh && chmod +x box.sh && clear && ./box.sh

Input 18

image

Input the RAM you want to swap, normally it is 2 * orginial RAM

For example, the original RAM of the linux server is 1G = 1024 MB, then we input 2048 here

image

3. Install Docker and Docker-compose

Install Docker

wget -qO- get.docker.com | bash

Check Docker version

docker -v

image

Run docker on startup

systemctl enable docker

image

Install Docker-compose

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

Check docker-compose version

docker-compose --version

image

Modify docker config (Optional)

cat > /etc/docker/daemon.json <<EOF
{
    "log-driver": "json-file",
    "log-opts": {
        "max-size": "20m",
        "max-file": "3"
    },
    "ipv6": true,
    "fixed-cidr-v6": "fd00:dead:beef:c0::/80",
    "experimental":true,
    "ip6tables":true
}
EOF

Restart Docker service

systemctl restart docker

Check if the port 81 has been used by existing apps/services

sudo -i
cd ~
apt install lsof
lsof -i:81

The result below shows that port 81 is not used by other apps/services

image

mkdir -p /root/data/docker_data/npm
cd /root/data/docker_data/npm

Create docker-compose yaml file and paste the content below

vim docker-compose.yml
version: '3.8'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      # These ports are in format <host-port>:<container-port>
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
      # Add any other Stream port you want to expose
      # - '21:21' # FTP
    environment:
      # Mysql/Maria connection parameters:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm"
      DB_MYSQL_NAME: "npm"
      # Uncomment this if IPv6 is not enabled on your host
      # DISABLE_IPV6: 'true'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    depends_on:
      - db

  db:
    image: 'jc21/mariadb-aria:latest'
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: 'npm'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm'
    volumes:
      - ./mysql:/var/lib/mysql

image

Start Nginx proxy manager

cd /root/data/docker_data/npm
docker-compose up -d

image

5. Access your Nginx proxy manager

Navigate to <IP of the host>:81 in the browser, you will see the login page below

You can check the IP of the server by running the command

curl ip.sb

image

When the Nginx Proxy Manager first starts, log in with the following username and password:

Default Proxy Manager username:

admin@example.com

Default Proxy Manager password:

changeme

image

Once you log in, you can modify the username and password here

image

image

Now the Nginx proxy server is running on your machine

6. Enable and force SSL for Nginx proxy manager

a. Make sure you have a custom domain b. Add DNS A record in your DNS provider, point FQDN to your Nginx proxy server's IP

For example,
You bought Domain "abc.com" from DNS provider.
Then you create FQDN "nginxproxy.abc.com" for your Nginx proxy server.
DNS A record > points "nginxproxy.abc.com" to the IP of Nginx proxy server.

c. How to get your custom domain

d. Enter the domain name you created for Nginx proxy manager, point to the IP of proxy server and port 81, and save

image

e. Once the entry is created, edit it

image

f. Force SSL

image

Optional

List docker images

docker image list

Clear unused docker image

docker image prune

About