Skip to content

Instantly share code, notes, and snippets.

@carlwgeorge
Last active July 10, 2020 16:42
Show Gist options
  • Save carlwgeorge/8704e092ab32d04612e3b7f180be2ad2 to your computer and use it in GitHub Desktop.
Save carlwgeorge/8704e092ab32d04612e3b7f180be2ad2 to your computer and use it in GitHub Desktop.
#!/usr/bin/bash
set -ue
name=$(basename $0)
utils_dir='/home/carl/sync/containers/utils'
if [[ "$name" == "run-image" ]]; then
echo "Don't run this directly, symlink it as the name you want to run."
exit 1
fi
podman_run_args="--interactive --tty --rm --hostname $name-container --network host --workdir /root"
if podman volume ls | grep -q $name-yum-cache; then
podman_run_args+=" --volume $name-yum-cache:/var/cache/yum:z"
fi
if podman volume ls | grep -q $name-dnf-cache; then
podman_run_args+=" --volume $name-dnf-cache:/var/cache/dnf:z"
fi
if [[ -d $utils_dir ]]; then
podman_run_args+=" --volume $utils_dir:/root/utils:z"
fi
if podman image exists $name; then
podman run $podman_run_args localhost/$name $@
else
echo "Cannot find image $name"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment