This utility image is a lightweight set of consistent Linux utilities, especially with
- base64
- bash
- curl
- jq
- sed
- shasum
- wget
- yq
To push it to latest, run ./push.sh
This is most useful when something like a DDEV add-on cannot count on a utility like shasum or jq to be on the host side (or be a predictable version).
Instead of using ddev describe -j | jq -r
for example, use ddev describe -j | docker run -t ddev/ddev-utilities jq -r
Classic utilities that are often different and unreliable on macOS include base64
and sed
Instead of running base64 -d
which may behave differently on different systems, use:
echo "somebase64content" | docker run -i --rm ddev/ddev-utilities base64 -d
docker run -i --rm ddev/ddev-utilities curl -I https://ddev.com
jq
is not available on all systems, but you can count on using it successfully with this image:
ddev describe -j | docker run -i --rm ddev/ddev-utilities jq -r .raw
sed
often behaves differently in BSD-derived systems like macOS
, so you can use it predictably like this:
ddev list -j | docker run -i --rm ddev/ddev-utilities bash -c "jq -r .raw | sed 's/ddev\.site/tld/g'"
Instead of running shasum directly (its behavior can vary radically from system to system), use
echo $RANDOM | docker run -i --rm ddev/ddev-utilities shasum -a 256
docker run -it --rm -v ./:/pwd -u $(id -u):$(id -g) -w /pwd ddev/ddev-utilities bash -c "wget -qO- https://github.com/ddev/ddev/releases/download/v1.23.4/ddev_shell_completion_scripts.v1.23.4.tar.gz | tar xz --strip-components=1"
yq
is used to modify YAML files. Example to add simple post-start hook to DDEV:
hooks:
post-start:
- exec-host: ddev mailpit
docker run -i --rm -v ./:/pwd -u $(id -u):$(id -g) -w /pwd ddev/ddev-utilities yq -I4 -i '.hooks."post-start"[0]."exec-host" = "ddev mailpit"' .ddev/config.yaml
See Use push.sh here
To run the container by itself:
docker run -it --rm ddev/ddev-utilities
https://github.com/ddev/ddev-utilities