Docker部署 Alist

一、什么是 Alist?

Alist 是一个基于 Go 语言开发的轻量级网盘目录列表和文件管理系统,支持多种存储后端(本地、OneDrive、阿里云盘等),界面简洁,部署简单。


二、准备条件

  • 已安装好 Docker 和 Docker Compose(可选)
  • 主机有可用端口(默认 5244)
  • 推荐映射数据目录持久化配置和文件

三、Docker 方式快速部署 Alist

1. 直接使用 Docker 命令启动

lua 复制代码
docker run -d \
  --name alist \
  -p 5244:5244 \
  -v /path/to/alist/data:/data \
  -v /path/to/alist/config:/config \
  --restart unless-stopped \
  xhofe/alist
php
162 Bytes
© 菜鸟-创作你的创作
  • -p 5244:5244:将容器内 5244 端口映射到宿主机 5244 端口
  • -v /path/to/alist/data:/data:映射文件存储目录(自己放文件的目录)
  • -v /path/to/alist/config:/config:映射配置目录(Alist 配置文件存放地)
  • --restart unless-stopped:容器自动重启策略

启动后浏览器访问 http://你的服务器IP:5244,默认账号密码均是 admin。


2. 使用 Docker Compose 部署示例

创建 docker-compose.yml:

ruby 复制代码
version: '3'
services:
  alist:
    image: xhofe/alist
    container_name: alist
    restart: unless-stopped
    ports:
      - "5244:5244"
    volumes:
      - /path/to/alist/data:/data
      - /path/to/alist/config:/config
php
224 Bytes
© 菜鸟-创作你的创作

运行:

复制代码
docker-compose up -d
php
20 Bytes
© 菜鸟-创作你的创作

四、常用操作

  • 查看日志:

    docker logs -f alist
    php
    20 Bytes
    © 菜鸟-创作你的创作

  • 进入容器:

bash 复制代码
docker exec -it alist /bin/sh
php
29 Bytes
© 菜鸟-创作你的创作
  • 停止容器:
arduino 复制代码
docker stop alist
php
17 Bytes
© 菜鸟-创作你的创作
  • 启动容器:
sql 复制代码
docker start alist
php
18 Bytes
© 菜鸟-创作你的创作

五、配置持久化和备份

  • /path/to/alist/config 目录保存 Alist 的所有配置文件,备份此目录即可备份配置。
  • /path/to/alist/data 是你共享的文件存储目录。

六、其他参考


明白!下面帮你写一个基于 Nginx 反向代理 + HTTPS 的完整示例,配合 Docker 部署的 Alist 做安全访问。


一、准备条件

  • 你的服务器能访问外网,已安装 Docker 和 Docker Compose。
  • 域名已解析到服务器公网 IP。
  • 安装了 Nginx(可用宿主机或 Docker 内 Nginx)。
  • 获取 SSL 证书(推荐使用 Let's Encrypt 免费证书)。

二、示例结构说明

bash 复制代码
/alist/
├── docker-compose.yml
└── nginx/
    ├── alist.conf
    ├── ssl/
        ├── fullchain.pem
        └── privkey.pem
php
123 Bytes
© 菜鸟-创作你的创作

三、步骤详解

1. Docker Compose 配置(alist/docker-compose.yml)

yaml 复制代码
version: '3'
services:
  alist:
    image: xhofe/alist
    container_name: alist
    restart: unless-stopped
    ports:
      - "5244:5244"          # 暴露容器端口,不直接外网访问
    volumes:
      - ./data:/data
      - ./config:/config
php
224 Bytes
© 菜鸟-创作你的创作

2. Nginx 配置(alist/nginx/alist.conf)

ini 复制代码
server {
    listen 80;
    server_name your.domain.com;
    # 强制重定向到 HTTPS
    return 301 https://$host$request_uri;
}
server {
    listen 443 ssl;
    server_name your.domain.com;
    ssl_certificate /etc/nginx/ssl/fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;
    location / {
        proxy_pass http://localhost:5244/;    # 反向代理到 Alist 容器映射端口
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        # WebSocket 支持(如果需要)
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}
php
813 Bytes
© 菜鸟-创作你的创作

注意:将 your.domain.com 替换成你的真实域名。


3. 将 SSL 证书放到 nginx/ssl 目录

  • 使用 Let's Encrypt 获取证书后,将 fullchain.pem 和 privkey.pem 放入该目录。

4. 启动服务

bash 复制代码
cd /alist
docker-compose up -d
php
30 Bytes
© 菜鸟-创作你的创作

启动 Nginx(假设是宿主机 Nginx,执行 nginx -s reload 使配置生效)


5. 访问测试

打开浏览器访问:

arduino 复制代码
https://your.domain.com
php
23 Bytes
© 菜鸟-创作你的创作

应该可以看到 Alist 的登录页面。


四、补充建议

  • 安全:登录后及时修改默认密码。
  • 防火墙:只开放 80/443 端口,关闭 5244 端口外网访问。
  • 自动续期:使用 certbot 配合定时任务自动续期 Let's Encrypt 证书。

明白!这里帮你写一个 Docker Compose 一体化部署 Alist + Nginx + Certbot 自动续期 HTTPS 的完整示例,适合快速启动并自动维护证书。


一、目录结构示范

bash 复制代码
alist-docker/
├── docker-compose.yml
├── nginx/
│   ├── conf.d/
│   │   └── alist.conf
│   └── certs/          # 证书文件会自动挂载到这里
└── data/               # Alist 数据目录
└── config/             # Alist 配置目录
php
199 Bytes
© 菜鸟-创作你的创作

二、docker-compose.yml 内容

yaml 复制代码
version: '3.8'
services:
  alist:
    image: xhofe/alist
    container_name: alist
    restart: unless-stopped
    volumes:
      - ./data:/data
      - ./config:/config
    expose:
      - "5244"    # 只暴露给内网,不映射到宿主机
    networks:
      - alist-net
  nginx:
    image: nginx:stable-alpine
    container_name: alist-nginx
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./nginx/certs:/etc/nginx/certs:ro
    depends_on:
      - alist
    networks:
      - alist-net
  certbot:
    image: certbot/certbot
    container_name: certbot
    volumes:
      - ./nginx/certs:/etc/letsencrypt
      - ./nginx/conf.d:/etc/nginx/conf.d
    entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew --webroot -w /var/www/certbot --quiet; sleep 12h & wait $${!}; done;'"
    networks:
      - alist-net
networks:
  alist-net:
    driver: bridge
php
930 Bytes
© 菜鸟-创作你的创作

三、Nginx 配置(nginx/conf.d/alist.conf)

ini 复制代码
server {
    listen 80;
    server_name your.domain.com;
    location /.well-known/acme-challenge/ {
        root /var/www/certbot;
    }
    location / {
        return 301 https://$host$request_uri;
    }
}
server {
    listen 443 ssl http2;
    server_name your.domain.com;
    ssl_certificate /etc/nginx/certs/live/your.domain.com/fullchain.pem;
    ssl_certificate_key /etc/nginx/certs/live/your.domain.com/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;
    location / {
        proxy_pass http://alist:5244/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}
php
898 Bytes
© 菜鸟-创作你的创作

记得替换 your.domain.com 为你的真实域名。


四、初次申请证书命令示范

第一次运行前,需要先手动申请证书,示例:

bash 复制代码
docker run --rm -it \
  -v $(pwd)/nginx/certs:/etc/letsencrypt \
  -v $(pwd)/nginx/conf.d:/etc/nginx/conf.d \
  certbot/certbot certonly --webroot \
  --webroot-path=/var/www/certbot \
  --email your-email@example.com \
  --agree-tos --no-eff-email \
  -d your.domain.com
php
271 Bytes
© 菜鸟-创作你的创作

五、启动步骤

  1. 修改 alist.conf 中的域名。

  2. 手动申请证书(步骤四)。

  3. 启动服务:

    docker-compose up -d
    php
    20 Bytes
    © 菜鸟-创作你的创作

  4. 访问 https://your.domain.com 验证。


六、自动续期说明

  • certbot 容器会每12小时执行一次证书续期,自动更新。
  • Nginx 证书目录绑定共享,更新后无需手动重启容器。

www.52runoob.com/archives/54...

相关推荐
行百里er11 小时前
Redis 完结篇——Redis 热点问题在 Spring Boot 项目中实战
redis·后端
高频因子挖掘机12 小时前
只取最近 60 个交易日,却每次拉全历史:量化脚本变慢的原因与改法
后端·github·api
孟健12 小时前
从5000亿Token到83%字节匹配:AI逆向工程与重构的工程闭环实践
后端·架构·ai编程
码事漫谈13 小时前
丢得静悄悄,谈一谈 Agent 的记忆是怎么没的
后端
迪飞特科技13 小时前
智慧物业平台实战:Spring Boot 整合小程序实现报修巡检费用全流程
spring boot·后端·小程序
考虑考虑13 小时前
@JsonInclude注解使用
spring boot·后端·spring
IT_陈寒14 小时前
Vite的这个问题坑了我三天,原来如此解决!
前端·人工智能·后端
网易云信14 小时前
大模型能上岗做销售吗?我们让 12 款国产模型交了 420 份作业
前端·后端
CCblandy14 小时前
HTTP 长连接 3 类故障实测:[WinError 10053]、99 个 TIME_WAIT、69 次多余握手,4 种对策怎么选
后端·python·网络协议·http·云原生·性能优化·架构
蜗牛互联网14 小时前
Python Agent工具调用的白名单、参数校验与审批门禁
java·服务器·前端·人工智能·后端·python