Docker Python Lab logo

Docker Python Lab

Community
dmccreary
docker-python-lab

Generates an interactive Docker Python lab block for MkDocs textbook pages, where students write and run real Python code inside an isolated Docker container. Use this skill whenever someone asks to add a Python lab, code runner, interactive Python exercise, or runnable code block to a textbook page that uses Docker (not Skulpt). Also use it when adding multiple labs to a single page, setting up the shared CSS/JS infrastructure, or creating a timing/benchmark lab that shows students how long each phase takes. Always invoke this skill instead of writing docker lab HTML by hand.

Overview

Publisherdmccreary
Repositoryibook-skills
Skill namedocker-python-lab
Stars
109
Forks
21
Bundled files
3
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by dmccreary on GitHub. Read the source before you install it.

Installation

Install the Docker Python Lab AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/dmccreary/ibook-skills/tree/main/skills/archived/docker-python-lab
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dmccreary/ibook-skills.git /tmp/ibook-skills
mkdir -p .claude/skills
cp -r /tmp/ibook-skills/skills/archived/docker-python-lab .claude/skills/docker-python-lab
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Docker Python Lab in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Docker Python Lab on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Docker Python Lab is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Docker Python Lab Generator

What This Skill Does

Generates interactive Python lab blocks for MkDocs pages in the learning-python textbook (or any MkDocs project following the same pattern). Each lab shows a code editor, Run and Reset buttons, and an output area. Code runs inside a fresh, isolated Docker container via a local HTTP service on port 5001.

This is the Docker counterpart to the Skulpt lab pattern — same look and feel, but students run real Python (not browser-emulated Python) with access to the full standard library and third-party packages.


Prerequisites: Shared Infrastructure

Before generating any lab block, make sure the shared files exist. Check once per session; skip if already in place.

1. Check / create docs/css/docker-lab.css

If the file is missing, copy from the skill's assets:

bash
cp ~/.claude/skills/docker-python-lab/assets/docker-lab.css \
   docs/css/docker-lab.css

2. Check / create docs/js/docker-lab.js

bash
cp ~/.claude/skills/docker-python-lab/assets/docker-lab.js \
   docs/js/docker-lab.js

3. Add to mkdocs.yml (if not already present)

Check extra_css and extra_javascript in mkdocs.yml. If the entries are missing, add them:

yaml
extra_css:
  - css/docker-lab.css      # ← add this line

extra_javascript:
  - js/docker-lab.js        # ← add this line

Do not duplicate entries that are already there.

4. Verify the service script exists

The runtime service lives at scripts/run-python-docker.sh. If it is missing from the project, tell the user — the labs won't work without it.


Lab HTML Template

Each lab needs a unique suffix — a short string that distinguishes it from other labs on the same page. Use "1" for the first lab, "2" for the second, and so on. The suffix appears in every element ID so the JS can find the right elements.

Standard lab (text output only)

html
<div id="docker-lab-SUFFIX">
<div id="docker-editor-SUFFIX">
<textarea id="docker-code-SUFFIX" spellcheck="false">PYTHON_CODE_HERE
</textarea>
<div id="docker-buttons-SUFFIX">
  <button id="docker-run-SUFFIX" onclick="runDocker('SUFFIX')">&#9654; Run</button>
  <button id="docker-reset-SUFFIX" onclick="resetDocker('SUFFIX')">&#8635; Reset</button>
</div>
<pre id="docker-output-SUFFIX" class="docker-output">Output will appear here after you click Run.</pre>
</div>
</div>

Rules:

  • Replace every SUFFIX with the same string (e.g., 1, 2, hello-world).
  • Put the Python code directly inside the <textarea> tag — no extra indentation relative to column 0, because leading spaces become part of the code.
  • The </textarea> closing tag must be on its own line with no trailing spaces before it; any blank line between the code and </textarea> adds an empty line in the editor.
  • Do not add rows="N" — the JS auto-sizes the textarea to fit the code.
  • Do not add id="main" to any element — that conflicts with the p5.js canvas parent convention used elsewhere in this project.

Timed lab (shows phase-by-phase timing breakdown)

Only add this variant when the lesson is specifically about how Docker execution works. It requires suffix "4" by convention and adds a timing table below the buttons.

html
<div id="docker-lab-4">
<div id="docker-editor-4">
<textarea id="docker-code-4" spellcheck="false">PYTHON_CODE_HERE
</textarea>
<div id="docker-buttons-4">
  <button id="docker-run-4" onclick="runDockerTimed()">&#9654; Run + Time</button>
  <button id="docker-reset-4" onclick="resetDockerTimed()">&#8635; Reset</button>
</div>
</div>
<div id="docker-timing-display" style="display:none; margin-top:12px;">
  <table id="docker-timing-table">
    <thead>
      <tr><th>#</th><th>Phase</th><th style="text-align:right">Time (ms)</th><th>Bar</th></tr>
    </thead>
    <tbody>
      <tr><td>1</td><td>Send to service (network)</td>
          <td id="td-network-send" style="text-align:right">—</td>
          <td><div class="timing-bar" id="bar-network-send"></div></td></tr>
      <tr><td>2</td><td>Container startup</td>
          <td id="td-startup" style="text-align:right">—</td>
          <td><div class="timing-bar" id="bar-startup"></div></td></tr>
      <tr><td>3</td><td>Python execution</td>
          <td id="td-exec" style="text-align:right">—</td>
          <td><div class="timing-bar" id="bar-exec"></div></td></tr>
      <tr><td>4</td><td>Return to browser (network)</td>
          <td id="td-network-return" style="text-align:right">—</td>
          <td><div class="timing-bar" id="bar-network-return"></div></td></tr>
      <tr style="font-weight:bold; border-top: 2px solid #642580;">
          <td colspan="2">Total round-trip</td>
          <td id="td-total" style="text-align:right">—</td>
          <td></td></tr>
    </tbody>
  </table>
  <p id="docker-timing-note" style="font-size:0.85em; color:#666; margin-top:6px;"></p>
</div>
<pre id="docker-output-4" class="docker-output" style="margin-top:10px;">Output will appear here after you click Run + Time.</pre>
</div>

Complete Page Pattern

A page with three labs looks like this:

markdown
# Page Title

Intro text explaining what the page covers and that students must run
`bash scripts/run-python-docker.sh` in a separate terminal first.

## Lab 1 — Hello, World!

Brief explanation of what this lab demonstrates.

<div id="docker-lab-1">
<div id="docker-editor-1">
<textarea id="docker-code-1" spellcheck="false">print("Hello, World!")
</textarea>
<div id="docker-buttons-1">
  <button id="docker-run-1" onclick="runDocker('1')">&#9654; Run</button>
  <button id="docker-reset-1" onclick="resetDocker('1')">&#8635; Reset</button>
</div>
<pre id="docker-output-1" class="docker-output">Output will appear here after you click Run.</pre>
</div>
</div>

**Try these experiments:**
- Change the message and run again.

---

## Lab 2 — Variables

<div id="docker-lab-2">
<div id="docker-editor-2">
<textarea id="docker-code-2" spellcheck="false">x = 42
print("The answer is", x)
</textarea>
<div id="docker-buttons-2">
  <button id="docker-run-2" onclick="runDocker('2')">&#9654; Run</button>
  <button id="docker-reset-2" onclick="resetDocker('2')">&#8635; Reset</button>
</div>
<pre id="docker-output-2" class="docker-output">Output will appear here after you click Run.</pre>
</div>
</div>

Choosing Good Lab Code

  • Keep starter code short (5–15 lines) so students can read it at a glance.
  • Every lab should produce visible output — at least one print() call.
  • Avoid input() — there is no stdin in the Docker runner.
  • Avoid file I/O — the container has no persistent filesystem.
  • Avoid import of non-stdlib packages unless python:3.11-alpine includes them (it ships only the stdlib).
  • Match the "See It — Run It — Modify It" rhythm from the Skulpt labs: starter code runs and shows something, then "Try these experiments" gives specific, achievable modifications.

Service Not Running — User-Facing Error

If a student clicks Run before starting the service, the lab shows:

Cannot connect to the Python Docker service. Please open a terminal and run: bash scripts/run-python-docker.sh Then reload this page and try again.

No extra error handling is needed in the page markdown — docker-lab.js handles this automatically.


Multiple Labs per Page — Checklist

When generating labs for a single page:

  • Each lab has a unique suffix — 1, 2, 3, …
  • Every element ID includes that suffix (docker-lab-1, docker-code-1, etc.)
  • Button onclick passes the matching suffix string: runDocker('2')
  • No two labs share a suffix on the same page
  • The page opens with a "Start the Docker service" instruction block
  • docs/css/docker-lab.css and docs/js/docker-lab.js are in mkdocs.yml

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Docker Python Lab AI skill do?

Generates an interactive Docker Python lab block for MkDocs textbook pages, where students write and run real Python code inside an isolated Docker container. Use this skill whenever someone asks to add a Python lab, code runner, interactive Python exercise, or runnable code block to a textbook page that uses Docker (not Skulpt). Also use it when adding multiple labs to a single page, setting up the shared CSS/JS infrastructure, or creating a timing/benchmark lab that shows students how long each phase takes. Always invoke this skill instead of writing docker lab HTML by hand.

Why use Docker Python Lab on TypingMind?

Because you install it once and use it with any model. Docker Python Lab is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Docker Python Lab in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/dmccreary/ibook-skills/tree/main/skills/archived/docker-python-lab. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Docker Python Lab?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Docker Python Lab?

As many as you like. As long as a model supports skills, you can use Docker Python Lab with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Docker Python Lab AI skill free?

It is published on GitHub by dmccreary. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇