☰ Categories

Create Python Dev Container

a DevOps expert setting up a Python development environment using Docker and VS Code Remote Containers.

CategoryDevelopment › Deploy & operations
TagsDraftingDeveloperCode
Prompt
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:
1. The docker pull command (if needed).
2. The full docker run command with all flags.
3. 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.

What this prompt does

This DevOps prompt sets up a Python slim-bookworm container for VS Code Remote Containers. It requires a non-root vscode user, workspace mounting, and no host file creation beyond what is needed to run.

Model comparison

Gemini is most specific but mishandles permissions. ChatGPT likely uses an invalid tag, while [C] is missing.

GeminiTop overall
38/ 50

+ Provides specific flag explanations and VS Code steps.

- Recursive chown and effective-user handling are risky.

ChatGPT
35/ 50

+ Clearly summarizes the commands and attach steps.

- Uses an image tag that is likely nonexistent.

CriterionChatGPTGeminiLeader
Instruction following67Gemini +17%
Accuracy36Gemini +100%
Specificity89Gemini +13%
Structure99Tie
Right length97ChatGPT +29%

Scored 1–10 by gpt-5.6-sol with model names hidden (2026-09-25). This is an AI review, not a measurement.

Read full answers

We gave three models the same input and copied their answers unedited. Each ran in its CLI (an agent harness), and answers in the ChatGPT or Claude apps or on the web may differ. Outputs are in Korean.

gpt-5.6-luna (codex CLI · 에이전트 하네스) · Run on 2026-09-24

아래 명령은 컨테이너를 생성한 뒤 필요한 도구를 설치하고, 최종 프로세스를 UID 1000의 vscode 사용자로 실행합니다.

docker pull python:latest-slim-bookworm
docker run -dit \
  --name py-dev-container \
  --user root \
  --workdir /workspace \
  --volume "$(pwd):/workspace:rw" \
  python:latest-slim-bookworm \
  bash -lc '
    set -eux
    apt-get update
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
      git curl ca-certificates build-essential
    useradd --uid 1000 --create-home --shell /bin/bash vscode 2>/dev/null || true
    exec su -s /bin/bash vscode -c "cd /workspace && exec bash -lc '\''sleep infinity'\''"
  '

--user root는 최초 실행 시 vscode 계정과 개발 도구를 생성하기 위한 부트스트랩 용도이며, 실제 계속 실행되는 프로세스는 vscode(UID 1000)입니다. --rm을 사용하지 않았으므로 컨테이너는 삭제되지 않습니다.

VS Code에서 연결하려면:

  1. VS Code 확장 기능에서 Dev Containers를 설치합니다.
  2. Cmd/Ctrl+Shift+P를 누릅니다.
  3. Dev Containers: Attach to Running Container... 를 선택합니다.
  4. py-dev-container를 선택합니다.
  5. 연결 후 /workspace에서 Python 프로젝트를 개발하면 됩니다.

컨테이너 상태 확인:

docker ps

중지하려면:

docker stop py-dev-container

현재 실행 환경에서는 Docker 데몬에 직접 명령을 실행할 수 없어 실제 컨테이너 생성 결과까지는 확인하지 못했습니다.

More in this category

AI Agent Architect — Design Production-Ready Agents in 15 Steps
AI Agent Security Evaluation Checklist
AI Provider Research Expert
AI Trying to Escape the Box
Analyze code scanning security issues and dependency updates if vulnerable