agentleFS
ai-enhanced-engineerai-enhanced-engineer/aiee-skills/skills/docker-python/SKILL.md

docker-python

Skill4 starsChanged 5 months agoMITView on GitHub

Docker patterns for Python 3.12+ applications. Debian Trixie breaking changes, OpenCV dependencies, setuptools compatibility, and port mapping verification. Use when building Dockerfiles for Python services.

  • Installs packages

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Port mapping: Verify docker-compose.yml host:container mapping (80:8000 != 8000:8000)

    line 24

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Docker Python Patterns

Debian Trixie Breaking Changes (Python 3.12+ base images)

ChangeOldNewImpact
OpenGL librarylibgl1-mesa-glxlibgl1OpenCV import cv2 fails at runtime
pkg_resourcesBundled with setuptoolsRemoved in setuptools 82+drf-yasg, django-rest-swagger crash on import

Fixes: apt-get install libgl1 and pip install 'setuptools<82' in Dockerfile.

Quick Reference

  • OpenCV apt deps: libgl1 libglib2.0-0 (minimal); add libsm6 libxext6 libxrender-dev for GUI
  • setuptools pin: RUN pip install 'setuptools<82' before packages using pkg_resources
  • Port mapping: Verify docker-compose.yml host:container mapping (80:8000 != 8000:8000)

CI System Dependencies (ubuntu-latest)

opencv-python on ubuntu-latest requires libgl1 libglib2.0-0 — install before uv sync or pip install. See reference.md for CI template and Example Project pipeline patterns.

EC2 Deployment Patterns

Bridge vs host networking: Bridge mode (-p 80:8000) maps container ports to SG-allowed host ports. Host networking exposes the process port directly — it may not match open SG rules (22, 80, 443).

Localhost-only bind behind TLS reverse proxy: When running Docker behind a TLS terminator (Caddy, nginx), bind container ports to 127.0.0.1 so external traffic cannot bypass TLS: -p 127.0.0.1:8000:8000. Default bridge publishing binds to 0.0.0.0 and becomes externally reachable if the SG allows the host port — a defense-in-depth gap. See caddy-tls-proxy for the full reverse-proxy topology.

Django runserver misleading output: Reports "System check identified no issues" even when it fails to bind. Use Gunicorn for production; verify binding with a health check endpoint.

Secrets and Env-File Patterns

Atomic writes: Writing secrets to a tmpfile then moving into place (mktemp + chmod 600 + mv) prevents partial reads during crashes. See examples.md for the atomic write pattern.

printf over heredoc: printf '%s\n' "$SECRET" is immune to shell metachar expansion ($, backticks, !). Unquoted heredocs expand these and corrupt values. printf is a bash builtin — secrets never appear in /proc/*/cmdline.

Docker --env-file gotcha: Docker's env-file parser treats # as a comment delimiter, silently truncating values containing #. docker run --env KEY=VALUE with proper shell quoting avoids this.

Production Persistence

SQLite + Docker + systemd: Systemd ExecStartPre: docker rm destroys the container filesystem. Named volumes (-v name:/path) survive docker rm and are auto-created on first use. See examples.md.

Anti-Patterns

Anti-PatternPattern
Installing libgl1-mesa-glx on TrixieUse libgl1 (meta-package removed)
Assuming pkg_resources is availablePin setuptools<82 for legacy packages
Trusting port numbers without checking composeVerify host:container mapping
Using opencv-python when headless sufficesUse opencv-python-headless in containers
--network host on EC2 behind security groupsBridge networking -p 80:8000 maps to SG-allowed ports
Django runserver "no issues" means server is readyUse Gunicorn; a health check endpoint confirms actual binding
Unquoted heredoc for secret interpolationprintf '%s\n' "$SECRET" — immune to metachar expansion
Docker --env-file with values containing #Use docker run --env KEY=VALUE or validate no # in values
Container-local SQLite without volume mountUse a named volume (-v name:/path); survives docker rm
--run-syncdb for apps with migration filesPlain manage.py migrate — --run-syncdb only works for unmigrated apps
Moving a compose file without pinning project nameCompose derives name from directory; old containers become orphans — down from the new path skips them. Pin with COMPOSE_PROJECT_NAME or name: in file. See reference.md.

See reference.md for Dockerfile examples, debugging commands, and OpenCV dependency matrix. See examples.md for secret handling, volume persistence, and entrypoint patterns.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.