防火墙放行端口:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --permanent --add-port=81/tcp
重载防火墙
sudo firewall-cmd --reload
尝试卸载旧版Docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
如果没有旧版 会提示没安装
安装yum-utils,并使用yum-config-manager设置docker仓库
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
安装Docker引擎(最新版)
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
启动Docker
sudo systemctl start docker
可选:把自己的用户名添加到Docker用户组(root无需)
sudo usermod -aG docker $USER
可选:跑一个测试容器验证docker安装成功:
sudo docker run hello-world
如果没有问题的话 会拉取hello-world的镜像并创建一个容器。
需要时选:卸载Docker引擎
sudo yum remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
需要时选:删除镜像 容器 和 配置文件等残留
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
安装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
创建一个专属于NPM的网络:
docker network create npm-nw
创建个文件夹用来存放Nginx Proxy Manager 并进入这个文件夹
mkdir ~/nginx-proxy
cd ~/nginx-proxy
在此文件夹下创建需要映射出来的子文件
mkdir {data,letsencrypt,www}
创建并编辑yml配置文件,nano或vi皆可
vi docker-compose.yml
配置文件内容:
version: "3"
services:
npm-app:
image: 'jc21/nginx-proxy-manager:latest'
container_name: npm-app
restart: unless-stopped
ports:
- '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:
DB_MYSQL_HOST: "npm-db"
DB_MYSQL_PORT: 3306
DB_MYSQL_USER: "npm"
DB_MYSQL_PASSWORD: "npm"
DB_MYSQL_NAME: "npm"
# Uncomment the line below if IPv6 is not enabled on your host
# DISABLE_IPV6: 'true'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
depends_on:
- npm-db
networks:
- npm-nw
- npm-internal
npm-db:
image: 'mariadb:latest'
container_name: npm-db
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: 'npm'
MYSQL_DATABASE: 'npm'
MYSQL_USER: 'npm'
MYSQL_PASSWORD: 'npm'
volumes:
- ./data/mysql:/var/lib/mysql
networks:
- npm-internal
networks:
npm-internal:
npm-nw:
external: true
端口可以修改为自己希望的端口
VI:ESC 冒号后wq退出
NANO: Ctrl+X 输入Y
启动NPM
docker-compose up -d
如果没有错误输入,说明安装成功
这时候可以用 http://ip-or-url:81 打开NPM的管理后台,默认用户名密码如下
admin@example.com
changeme
更新Nginx Proxy Manager
先停止容器:
cd ~/nginx-proxy
docker-compose down --remove-orphans
拉取新镜像
docker-compose pull
启动
docker-compose up -d
#Centos #Docker #Nginx proxy manager