Container-plane docker now routes through the mode-aware helpers instead of sudo: simple calls (exec/ps/run/build/images/inspect/port/logs across ~15 app/check scripts) -> runFileOp docker (rootless socket as the install user; rooted via the docker group). The cd && docker compose paths drop the sudo on the rooted branch (the rootless branch already used dockerCommandRunInstallUser -- byte-identical now, manager-ready later); gluetun, which had no rootless branch, now uses dockerCommandRun so force-recreate works in both modes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: librelad <librelad@digitalangels.vip>
40 lines
1.4 KiB
Bash
40 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
dockerRemoveAppImages()
|
|
{
|
|
local app_name="$1"
|
|
|
|
if [[ -z "$app_name" ]]; then
|
|
isNotice "No app name provided. Unable to remove Docker images."
|
|
return
|
|
fi
|
|
|
|
isNotice "Removing Docker images for '$app_name'. Please wait..."
|
|
|
|
local compose_dir="$containers_dir$app_name"
|
|
local compose_file="$compose_dir/docker-compose.yml"
|
|
local compose_images=""
|
|
|
|
if [[ -f "$compose_file" ]]; then
|
|
if [[ $CFG_DOCKER_INSTALL_TYPE == "rootless" ]]; then
|
|
compose_images=$(dockerCommandRunInstallUser "cd $compose_dir && docker compose config --images" 2>/dev/null)
|
|
elif [[ $CFG_DOCKER_INSTALL_TYPE == "rooted" ]]; then
|
|
compose_images=$(cd "$compose_dir" && docker compose config --images 2>/dev/null)
|
|
fi
|
|
fi
|
|
|
|
local matched_images=$(dockerCommandRun "docker images --format '{{.Repository}}:{{.Tag}}' | grep -E '(^|/)${app_name}(-|_|:|$)'" 2>/dev/null)
|
|
|
|
local all_images=$(printf "%s\n%s\n" "$compose_images" "$matched_images" | sort -u | grep -v '^$' | grep -v '<none>')
|
|
|
|
if [[ -z "$all_images" ]]; then
|
|
isNotice "No Docker images found for '$app_name'."
|
|
return
|
|
fi
|
|
|
|
while IFS= read -r image; do
|
|
local result=$(dockerCommandRun "docker rmi -f '$image'" >/dev/null 2>&1)
|
|
checkSuccess "Removed Docker image '$image'"
|
|
done <<< "$all_images"
|
|
}
|