Person/Zack Steinkamp/Blog/21/05/The Best Ways To Run a Short Script in a Container
Properties
- created-by
- Person/Zack Steinkamp
- date-created
- 21/05
- tags
- Blog/Post
The Best Ways To Run a Short Script in a Container
My Notes
- Person/Zack Steinkamp describes two ways to run script/CLI-style tasks from the shell via Docker without maintaining a separate Dockerfile and compose/runner script for each task.
- containerscript: Single Bash script that inlines the Dockerfile, build/run commands, and the script to run (see Gist).
- Turdokken: Shebang-line tool; install in
$PATHand use as shebang so scripts declare dependencies (e.g.--install mysql-client) and run in a container. Repo: GitHub/zsteinkamp/turdokken.
dockerscript- One Bash script defines the Dockerfile, Docker build/run commands, and the script to run. Replace the
cmd()function and adjust theFROMline orRUNcommands for dependencies. - Example GitHub/Gist
- One Bash script defines the Dockerfile, Docker build/run commands, and the script to run. Replace the
GitHub/zsteinkamp/turdokken
- If one uses
turdokkenas the shebang, then scripts run in a container with declared dependencies. - Install Turdokken in
$PATH; shebang must be#!/usr/bin/env -S turdokken. - Example script:
- Running
./myscript.sh foo barruns the script inside a container that hasmysql-clientinstalled; Turdokken builds the image, runs the container, mounts the script, and invokes it with bash. You can mount local files for reading or modification.
- If one uses