Docker 环境使用

目前 ChatGPT Plus、Team、Pro 等付费会员都可以使用,直接在网页版就有 Codex 入口。

如果在 windows 下已经通过打开 chatgpt.com 认证,可以直接复制认证文件过去即可

cp /opt/mnt/e/workspace/auth.json /opt/mnt/e/workspace/config.toml ~/.codex/

services:
  php74:
    image: php:php-74-fpm-nginx-supervisor-alpine-20250918
    container_name: php74
    restart: unless-stopped
    networks:
      - shared-network
    ports:
      - 80:80
    volumes:
      - /var/www/html:/var/www/html2
      - /root/.codex:/root/.codex
networks:
  shared-network:
    external: true
# alpine v3.16
root@localhost:~# docker exec -it php74 /bin/sh
/var/www/html # apk update
/var/www/html # apk add --no-cache bash curl git nodejs npm
/var/www/html # npm install -g @openai/codex

完成后显示一个炫酷的图标,然后让你选择认证的方式,打开Url或者输入API Key。

> 1. Sign in with ChatGPT
     Usage included with Plus, Pro, and Team plans
  2. Provide your own API key
     Pay for what you use

使用方法

/opt/mnt/e/www/app # history
   0 ls
   1 ls /opt/mnt/e/
   2 ping google.com
   3 apk add --no-cache bash curl git python3 py3-pip nodejs npm build-base
   4 npm -v
   5 node -v
   6 npm install -g @openai/codex
   7 codex --version
   8 cd /opt/mnt/e/www/app
   9 ls
  10 codex
  11 cp /opt/mnt/e/workspace/auth.json /opt/mnt/e/workspace/config.toml ~/.codex/
  12 ls
  13 ls ~/.codex/
  14 codex --version
  15 codex -help
  16 codex
  17 history

参考资料

  • ChatGPT Plus(其它自行查阅)使用限制:本地任务:普通用户每5小时可以发送30-150条消息,每周有限制。 https://help.openai.com/zh-hans-cn/articles/11369540-using-codex-with-your-chatgpt-plan#h_d93a168dde