Docker Portainer with Let's Encrypt 使用教程
1. 项目的目录结构及介绍
docker-portainer-letsencrypt/
├── docker-compose.yml
├── docker-compose-with-password.yml
├── LICENSE
├── README.md
├── start.sh
└── stop.sh
docker-compose.yml
: 主配置文件,用于启动 Portainer 容器。docker-compose-with-password.yml
: 带有密码保护的配置文件。LICENSE
: 项目许可证文件,采用 LGPL-3.0 许可证。README.md
: 项目说明文档。start.sh
: 启动脚本。stop.sh
: 停止脚本。
2. 项目的启动文件介绍
start.sh
启动脚本 start.sh
用于简化 Portainer 容器的启动过程。脚本内容如下:
#!/bin/bash
docker-compose up -d
stop.sh
停止脚本 stop.sh
用于停止 Portainer 容器。脚本内容如下:
#!/bin/bash
docker-compose down
3. 项目的配置文件介绍
docker-compose.yml
主配置文件 docker-compose.yml
包含了 Portainer 容器的详细配置,包括网络、卷映射、环境变量等。以下是部分关键配置:
version: '3.7'
services:
portainer:
image: portainer/portainer-ce:latest
container_name: portainer
restart: always
ports:
- "9443:9443"
- "8000:8000"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
- /etc/letsencrypt/live/yourdomain:/certs/live/yourdomain:ro
- /etc/letsencrypt/archive/yourdomain:/certs/archive/yourdomain:ro
command:
- --sslcert /certs/live/yourdomain/fullchain.pem
- --sslkey /certs/live/yourdomain/privkey.pem
volumes:
portainer_data:
docker-compose-with-password.yml
带有密码保护的配置文件 docker-compose-with-password.yml
包含了额外的安全设置,例如设置管理员密码。以下是部分关键配置:
version: '3.7'
services:
portainer:
image: portainer/portainer-ce:latest
container_name: portainer
restart: always
ports:
- "9443:9443"
- "8000:8000"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
- /etc/letsencrypt/live/yourdomain:/certs/live/yourdomain:ro
- /etc/letsencrypt/archive/yourdomain:/certs/archive/yourdomain:ro
environment:
- ADMIN_PASSWORD=your_password
command:
- --sslcert /certs/live/yourdomain/fullchain.pem
- --sslkey /certs/live/yourdomain/privkey.pem
volumes:
portainer_data:
以上是 Docker Portainer with Let's Encrypt 项目的详细使用教程,包括目录结构、启动文件和配置文件的介绍。希望对您有所帮助!