# my-docker-dev **Repository Path**: happygroup_1/my-docker-dev ## Basic Information - **Project Name**: my-docker-dev - **Description**: 用于不同语言的docker开发和运行库 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-01-20 - **Last Updated**: 2025-01-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### 用docker搭建python 运行和开发环境 **1.构建开发环境** **1.1 规约** ``` make 语言-版本-类型-用途 ``` **1.2 例子** ``` make python-3.9.21-dev-slim ``` **2.已经支持的库** **一个轻量级的python 3.9.21** ``` python-3.9.21-dev-slim #支持调试 python-3.9.21-slim #不支持调试 ``` **3.(ing,调试时找不到库)如何使用vscode+docker容器进行调试** --- 参考 https://blog.csdn.net/destiny44123/article/details/144191740 **3.1 编写如下文件,用于将库安装到docker容器中** ``` # Start with a Python 3.9 base image FROM chenjingdong/python-3.9.21-dev-slim:1.0 # Set the working directory in the container WORKDIR /app # Copy the current directory contents into the container at /app COPY ./requirements.txt /app # Install the project dependencies RUN pip install --no-cache-dir -r /app/requirements.txt ``` **3.2编写docker-compose.yml进行调试** ``` services: chatdev: image: chenjingdong/chat-dev-v1-dev:250119 container_name: chatdev environment: - OPENAI_API_KEY=${OPENAI_API_KEY} - MODEL_NAME=${MODEL_NAME} - BASE_URL=${BASE_URL} volumes: - ../:/app working_dir: /workspace ports: - "5678:5678" #调试使用 - "8000:8000" #功能相关 command: #这是一个阻塞脚本,例如可以使用 while true; do sleep 10; done - /app/blocking.sh ``` **3.3 运行并进行调试** ``` #注意:这里docker-compose-dev.yml是在指令执行的we-chat-dev-docker子目录下 docker-compose -f we-chat-dev-docker/docker-compose-dev.yml up -d ``` **3.4 编写调试配置launch.json文件** **3.4.1 attach容器中的程序(未实际验证过)** ```json { "version": "0.2.0", "configurations": [ { "name": "Python: Remote Attach", "type": "python", "request": "attach", "connect": { "host": "localhost", "port": 5678 }, "pathMappings": [ { "localRoot": "${workspaceFolder}/", // Adjust this to the local path "remoteRoot": "/app" // Adjust this to the remote path in the container } ] } ] } ``` **3.4.2 启动并调试容器中的程序(亲测可用)** --- 这种方式可以在vscode中直接启动运行,十分方便 ```json { "version": "0.2.0", "configurations": [ { "name": "Python Debugger: Remote Lanch", "type": "debugpy", "request": "launch", "program": "/app/run.py", "args": ["--task","\"完成一个计算器.\"","--name","\"human\"","--org","zjc","--model","DEEP_SEEK","--rd","no"], "cwd": "/app", "pythonPath": "/usr/local/bin/python", "pathMappings": [ { "localRoot": "${workspaceFolder}/", // Adjust this to the local path "remoteRoot": "/app" // Adjust this to the remote path in the container } ] } ] } ``` **100.FAQ** **100.1 参考资料** ``` https://zhuanlan.zhihu.com/p/673574425 ```