创建 Python 开发容器
配置 Docker 和 VS Code Remote Containers,使用官方 Python slim-bookworm 镜像搭建轻量级开发环境。
提示词正文
复制后可直接粘贴到模型或内部评测工具。
You are a DevOps expert setting up a Python development environment using Docker and VS Code Remote Containers.
Your task is to provide and run Docker commands for a lightweight Python development container based on the official python latest slim-bookworm image.
Key requirements:
- Use interactive mode with a bash shell that does not exit immediately.
- Override the default command to keep the container running indefinitely (use sleep infinity or similar) do not remove the container after running.
- Name it py-dev-container
- Mount the current working directory (.) as a volume to /workspace inside the container (read-write).
- Run the container as a non-root user named 'vscode' with UID 1000 for seamless compatibility with VS Code Remote - Containers extension.
- Install essential development tools inside the container if needed (git, curl, build-essential, etc.), but only via runtime commands if necessary.
- Do not create any files on the host or inside the container beyond what's required for running.
- Make the container suitable for attaching VS Code remotely (Remote - Containers: Attach to Running Container) to enable further Python development, debugging, and extension usage.
Provide:
- The docker pull command (if needed).
- The full docker run command with all flags.
- Instructions on how to attach VS Code to this running container for development.
Assume the user is in the root folder of their Python project on the host.
使用场景
参考输出
docker pull python:3.12-slim-bookworm docker run -it --name py-dev-container -v $(pwd):/workspace -u 1000:1000 python:3.12-slim-bookworm bash -c "sleep infinity"
评分维度
正确使用 slim-bookworm 镜像,设置非 root 用户,挂载目录,保持容器运行,提供 VS Code 附加步骤。
试用与模板
填写变量后复制,或保存到个人工作台模板。
这个模板没有变量,可直接复制使用。
用户评分
0 个评分你的评分
登录后评分
评论
0登录后评论
相关提示词
Linux 监控 HTML 仪表盘生成器
生成一个用于 Linux Ubuntu 系统的现代化监控仪表盘,集成 Docker 状态与磁盘 IO 吞吐量,支持多种刷新频率,并采用 React 组件库和 Quicksand 字体构建精美界面。
SpringBoot REST API的CI/CD策略
针对SpringBoot多API monorepo的CI/CD流水线设计,涵盖CloudBees Jenkins、Docker镜像、Kubernetes部署及蓝绿发布。