小白如何优雅部署及管理Docker服务
- 在Docker中创建一个名为
nginx_net
的网络
docker network create nginx_net
version: "3.8"
networks:
nginx_net:
external: true
services:
dockge:
image: louislam/dockge:1
container_name: dockge
restart: unless-stopped
networks:
- nginx_net
ports:
# Host Port : Container Port
- 5001:5001
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./data:/app/data
# If you want to use private registries, you need to share the auth file with Dockge:
# - /root/.docker/:/root/.docker
# Stacks Directory
# ⚠️ READ IT CAREFULLY. If you did it wrong, your data could end up writing into a WRONG PATH.
# ⚠️ 1. FULL path only. No relative path (MUST)
# ⚠️ 2. Left Stacks Path === Right Stacks Path (MUST)
- ./stacks:/opt/stacks
environment:
# Tell Dockge where is your stacks directory
- DOCKGE_STACKS_DIR=/opt/stacks
- 使用Dockge安装nginx-proxy-manager,注意Dockge中的docker-compose文件映射目录最好是绝对路径,个人喜欢统一放在opt目录下
version: '3.8'
networks:
nginx_net:
external: true
services:
nginx-proxy-manager:
image: 'jc21/nginx-proxy-manager:latest'
container_name: nginx-proxy-manager
restart: unless-stopped
networks:
- nginx_net
ports:
- '80:80' # Public HTTP Port
- '443:443' # Public HTTPS Port
- '81:81' # Admin Web Port
environment:
DISABLE_IPV6: 'true'
volumes:
- /opt/nginx-proxy-manager/data:/data
- /opt/nginx-proxy-manager/letsencrypt:/etc/letsencrypt
DNS解析时主域名填写服务器IP,二级域名CNAME指向主域名,nginx-proxy-manger里填写compose文件中容器名和容器内端口就可以了(注意容器要和nginx-proxy-manger在同一网络)
以上为个人部署和管理Docker服务步骤(仅供参考),如有不足还请指出
安装完这两个应用就可以愉快地部署其他Docker服务啦