Skip to content
Snippets Groups Projects
Commit dfa4bcb6 authored by Thomas Woerner's avatar Thomas Woerner
Browse files

infra/image/shcontainer: Volume support and new container_tee

This change adds support for volumes to container_create. Now it can be
used like in this example:

    container_create "${name}" "${local_image}" "hostname=${hostname}" \
        "${capabilities:+capabilities=$capabilities}" \
        volume=$PWD:/root/src

The new function container_tee has been added to enable creation of
fiiles with content from stdin like in this example:

    cat <<EOF | container_tee "${name}" "/root/.gdbinit"
    set debuginfod enabled on
    set follow-fork-mode child
    EOF
parent fe58f3a8
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ container_create() { ...@@ -19,6 +19,7 @@ container_create() {
cpus=*) extra_opts+=("--${opt}") ;; cpus=*) extra_opts+=("--${opt}") ;;
memory=*) extra_opts+=("--${opt}") ;; memory=*) extra_opts+=("--${opt}") ;;
capabilities=*) extra_opts+=("--cap-add=${opt##*=}") ;; capabilities=*) extra_opts+=("--cap-add=${opt##*=}") ;;
volume=*) extra_opts+=("--volume=${opt##*=}") ;;
*) log error "container_create: Invalid option: ${opt}" ;; *) log error "container_create: Invalid option: ${opt}" ;;
esac esac
done done
...@@ -197,3 +198,15 @@ container_fetch() { ...@@ -197,3 +198,15 @@ container_fetch() {
podman cp "${name}:${source}" "${destination}" podman cp "${name}:${source}" "${destination}"
echo echo
} }
container_tee() {
local name=${1}
local destination=${2}
tmpfile=$(mktemp /tmp/container-temp.XXXXXX)
log info "= Creating ${name}:${filename} from stdin ="
cat - > ${tmpfile}
podman cp "${tmpfile}" "${name}:${destination}"
rm "${tmpfile}"
echo
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment