跳到内容

AutoGPT + Docker 指南

重要提示

使用 Compose 文件格式的 3.9 版本需要 Docker Compose 1.29.0 或更高版本。您可以通过运行以下命令检查系统上安装的 Docker Compose 版本

docker compose version

这将显示当前安装在您系统上的 Docker Compose 版本。

如果您需要将 Docker Compose 升级到更新版本,可以按照 Docker 文档中的安装说明进行操作:https://docs.docker.net.cn/compose/install/

基本设置

  1. 确保您已安装 Docker,请参阅 requirements
  2. 为 AutoGPT 创建一个项目目录

    mkdir AutoGPT
    cd AutoGPT
    
  3. 在项目目录中,创建一个名为 docker-compose.yml 的文件

    对于 <= v0.4.7 的 docker-compose.yml

    version: "3.9"
    services:
      auto-gpt:
        image: significantgravitas/auto-gpt
        env_file:
          - .env
        profiles: ["exclude-from-up"]
        volumes:
          - ./auto_gpt_workspace:/app/auto_gpt_workspace
          - ./data:/app/data
          ## allow auto-gpt to write logs to disk
          - ./logs:/app/logs
          ## uncomment following lines if you want to make use of these files
          ## you must have them existing in the same folder as this docker-compose.yml
          #- type: bind
          #  source: ./azure.yaml
          #  target: /app/azure.yaml
    

    对于 > v0.4.7(包括 master)的 docker-compose.yml

    version: "3.9"
    services:
      auto-gpt:
        image: significantgravitas/auto-gpt
        env_file:
          - .env
        ports:
          - "8000:8000"  # remove this if you just want to run a single agent in TTY mode
        profiles: ["exclude-from-up"]
        volumes:
          - ./data:/app/data
          ## allow auto-gpt to write logs to disk
          - ./logs:/app/logs
          ## uncomment following lines if you want to make use of these files
          ## you must have them existing in the same folder as this docker-compose.yml
          ## component configuration file
          #- type: bind
          #  source: ./config.json
          #  target: /app/config.json
    

  4. 下载 .env.template 并将其另存为 AutoGPT 文件夹中的 .env

  5. 遵循标准的 配置说明,从第 3 步开始,但不包括 poetry install 步骤。
  6. Docker Hub 拉取最新的镜像

    docker pull significantgravitas/auto-gpt
    
    4. 可选:挂载配置文件。如果您有组件配置文件,例如 config.json,请将其放在 classic/original_autogpt/data/ 目录中。或者将其放在 classic/original_autogpt/ 中并取消 docker-compose.yml 中挂载该文件的行的注释。要了解更多关于配置的信息,请参阅 组件配置

Docker 只支持无头浏览器

AutoGPT 默认使用无头模式的浏览器:HEADLESS_BROWSER=True。请不要在与 Docker 结合使用时更改此设置,否则 AutoGPT 将会崩溃。

开发者设置

提示

如果您已经克隆了仓库并且已经(或想要)对代码库进行修改,请使用此设置。

  1. .env.template 复制到 .env
  2. 遵循标准的 配置说明,从第 3 步开始,但不包括 poetry install 步骤。

使用 Docker 运行 AutoGPT

按照上面的设置说明后,您可以使用以下命令运行 AutoGPT

docker compose run --rm auto-gpt

这会创建并启动一个 AutoGPT 容器,并在应用程序停止后将其删除。这并不意味着您的数据会丢失:应用程序生成的数据存储在 data 文件夹中。

子命令和参数的使用方式与 用户指南 中描述的相同

  • 运行 AutoGPT
    docker compose run --rm auto-gpt serve
    
  • 在 TTY 模式下运行 AutoGPT,使用连续模式。
    docker compose run --rm auto-gpt run --continuous
    
  • 在 TTY 模式下运行 AutoGPT 并安装所有活动插件的依赖项
    docker compose run --rm auto-gpt run --install-plugin-deps
    

如果您敢,也可以使用“原生”docker 命令构建并运行它

docker build -t autogpt .
docker run -it --env-file=.env -v $PWD:/app autogpt
docker run -it --env-file=.env -v $PWD:/app --rm autogpt --gpt3only --continuous