Skip to content
Back to skills

Docker Customize

ASecurity

Customize a hermit Docker container through docker.packages, docker-build.hermit-local.sh, docker-entrypoint.hermit-local.sh or docker-compose.override.yml. Route apt packages, root toolchain installs, boot-time work, volumes, ports and env to their operator-owned surfaces. Convert an existing install to generated Docker files when requested.

  • 88 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 20, 2026
ai-agentsshellbashexpressdockergitapisecurity

Works with

  • claude code
  • terminal
  • cli
  • api

Security analysis

A100/100

Scanned November 19, 2026

npx -y skills add gtapps/claude-code-hermit --skill docker-customize --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Docker Customize?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Docker Customize
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gtapps-docker-customize/badge)](https://www.skillsdirectory.com/skills/gtapps-docker-customize)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: docker-customize
description: Customize a hermit Docker container through docker.packages, docker-build.hermit-local.sh, docker-entrypoint.hermit-local.sh or docker-compose.override.yml. Route apt packages, root toolchain installs, boot-time work, volumes, ports and env to their operator-owned surfaces. Convert an existing install to generated Docker files when requested.
---

# Docker Customize

Route each requested change to the surface below. `Dockerfile.hermit` and `docker-compose.hermit.yml` are plugin-owned. Their first line says `Generated by hermitd <version>` and names the four customization surfaces. Host `hermitd start`, `restart` and `update` render copies from `.hermit/config.json`. Keep both installed files until Convert succeeds on an unconverted install. Update the host plugin if the header names a newer version.

Files sit on the project bind mount, so file preparation can run inside the container or on the host. Locate the current shell with `[ -f /.dockerenv ] || [ -f /run/.containerenv ] && echo container || echo host`. Run plugin scripts with `bun "${CLAUDE_PLUGIN_ROOT}/scripts/<name>.ts"` on the host and `.hermit/bin/hermitd-run <name>` inside the container. Rebuild, restart and Compose validation require the host's Docker CLI. On an existing install, open the host wizard with `hermitd setup docker-customize`.

For personal and third-party skills, read [Personal and third-party skills in Docker](../../docs/creating-your-own-hermit.md#personal-and-third-party-skills-in-docker) and use the routes below for their dependencies.

## Apt packages

Add or remove packages through `/hermitd:hermit-settings docker`, which writes `docker.packages` using settings-edit and its protected-path prompt. Package names must match `^[a-z0-9][a-z0-9+\-.]+$`. Preserve packages the operator already chose.

Rebuild on the host with `hermitd restart --build`; from stopped, use `hermitd start --build`. The renderer reads the current list before the build. Removing a package from the list takes effect through that rebuild.

## Root and toolchain installs

Put root-only image setup in `<project-root>/docker-build.hermit-local.sh`. The image runs it with Bash as root after Claude Code and Bun are installed, then returns to `USER claude`. The file is optional and needs no executable bit. Preserve existing commands. Use `set -euo pipefail` so a failed install fails the build. For directories under `/home/claude`, use `install -d -o claude -g claude` and name every directory it creates, parents included (`install -d -o claude -g claude /home/claude/.local /home/claude/.local/share /home/claude/.local/share/tool`); it sets ownership only on the paths it names. The image's build context must include this file: if `.dockerignore` excludes everything by default, add `!docker-build.hermit-local.sh`.

Run `bash -n` on the hook. Apply it through the same host rebuild command as apt packages. The plugin never writes this file.

## Boot-time shell

Put boot-time work in `<project-root>/docker-entrypoint.hermit-local.sh`. Persist files under `.claude.local/`. The managed entrypoint sources it twice:

- `HERMIT_ENTRY_PHASE=pre-boot`: after channel directories and env resolution, before plugin installation.
- `HERMIT_ENTRY_PHASE=pre-launch`: immediately before `hermitd-start`; side services and last-second overrides.

The hook runs as claude under `set -euo pipefail`. Anchor paths to `${PROJECT_DIR}`. Preserve existing content and guard optional commands with `|| true`. Create it with `#!/usr/bin/env bash` if absent; it is sourced and needs no executable bit. Check with `bash -n`, and run session-safe commands once now if needed. `hermitd restart` applies boot changes without rebuilding.

## Volumes, ports and env

Write `<project-root>/docker-compose.override.yml`, preserving existing operator content. The stack order is base, security overlay if present, then operator override if present; the operator override wins. Use `!override` for a replacement list and `!reset` to remove an inherited value, rather than assuming ordinary list merging removes base entries. Keep API keys in `.env`; keys exported only in the host shell do not reach the container.

Before each validation command on the host, select the files again:

```bash
COMPOSE_FILES=(-f docker-compose.hermit.yml)
[ ! -f docker-compose.security.yml ] || COMPOSE_FILES+=(-f docker-compose.security.yml)
[ ! -f docker-compose.override.yml ] || COMPOSE_FILES+=(-f docker-compose.override.yml)
docker compose "${COMPOSE_FILES[@]}" config -q
```

After validation, the operator runs `hermitd restart` in a host terminal, adding `--build` when the image changed. The restart shows changed inputs and asks for approval. To review and approve them before restarting, run `hermitd approve` in the terminal. The override belongs to the operator.

## Convert

Convert existing Docker files only as a complete operation. If `Dockerfile.hermit` already has a first-line `Generated by hermitd <version>` header, run step 8 only and report **nothing to convert**.

1. Read both installed files and any existing build hook and override. Snapshot `Dockerfile.hermit` and `docker-compose.hermit.yml` to timestamped `.bak` copies under `.hermit/state/`. Keep those recovery copies through retries.
2. Run `bun "${CLAUDE_PLUGIN_ROOT}/scripts/settings-edit.ts" .hermit/config.json migrate browser-default-on` on the host. Preserve an existing browser decision. The migration accounts for an operator-installed browser.
3. Set `docker.git_identity_mount` with settings-edit from the installed compose mount targeting `/home/claude/.gitconfig`. A custom mount source must also be retained as a replacement in the override.
4. Reconcile `docker.packages` with the installed project-package apt install stanza, preserving operator-selected packages. Write the reconciled list with settings-edit. Do not guess when a shell expression prevents identifying the packages; report those lines as unplaced.
5. Render a candidate to a scratch directory inside the project with `bun "${CLAUDE_PLUGIN_ROOT}/scripts/render-docker-templates.ts" <project-root> --to <scratch-dir>`. Check the verdict for errors. Keep the installed files untouched. An existing entrypoint is preserved by the renderer.
6. Diff installed and candidate files. Account for **every** changed or removed operator line:
   - Move custom root commands from the marked customization stanza and root work added after `USER claude` to a candidate `docker-build.hermit-local.sh`. Strip Dockerfile `RUN` syntax into shell commands and omit Dockerfile `USER` switches. Convert `mkdir` under `/home/claude` to `install -d -o claude -g claude`, naming each directory the `mkdir -p` created, parents included. Use the boot hook for work intended to run on every boot.
   - Move added volumes, env and ports to a candidate `docker-compose.override.yml`.
   - Preserve changed or removed base entries through `!override` or `!reset`. Validate those tags on the host with `docker compose ... config -q`, selecting the scratch base, existing security overlay if present, and candidate override in that order. If validation cannot run or fails, leave the installed files untouched and report the affected lines as unplaced.
   - Build hook and override candidates as **whole files**, incorporating any pre-existing operator content verbatim. Never append conversion commands to live files: retries after interruption must not duplicate them. If a conflict prevents retaining existing content verbatim, report it as unplaced. Check the candidate shell hooks with `bash -n`.
7. Only after every edit is placed and the required checks pass, write the complete candidate hook and override, then run `bun "${CLAUDE_PLUGIN_ROOT}/scripts/render-docker-templates.ts" <project-root> --convert` in place. Check its verdict. Otherwise leave both installed Docker files untouched, write no partial migration to operator files, and report **each unplaced line** in chat.
8. After a successful `--convert`, delete the stale Docker merge state and step 5's scratch directory (omit it when step 5 did not run). Keep every `.bak` snapshot.
   ```bash
   rm -r .hermit/state/evolve-docker <scratch-dir> 2>/dev/null || true
   rm -f .hermit/state/Dockerfile.hermit.*.upstream* .hermit/state/docker-compose.hermit.yml.*.upstream* \
     .hermit/state/pristine/docker/Dockerfile.hermit.template .hermit/state/pristine/docker/docker-compose.hermit.yml.template
   m=.hermit/state/template-manifest.json
   [ ! -f "$m" ] || { jq 'del(.files["docker/Dockerfile.hermit.template"], .files["docker/docker-compose.hermit.yml.template"])' "$m" > "$m.tmp" && mv "$m.tmp" "$m"; } || rm -f "$m.tmp"
   ```

Report where each customization went and the snapshot paths. A retry starts from the installed files and existing operator surfaces and writes whole candidates, preserving previous operator content; the generated-header check makes a completed conversion a no-op. Ask the host to run the next `hermitd update` to regenerate again, rebuild and restart. An update-launched evolve leaves that build to the waiting host update. Tmux agents skip conversion.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.