#!/usr/bin/env bash set -e : "${BUILDX_CMD=docker buildx}" : "${TMUX=}" function clean { docker rmi $iid } iid=buildx-shell (set -x ; ${BUILDX_CMD} build --output "type=docker,name=$iid" --target shell .) trap clean EXIT SSH= if [ -n "$MOUNT_SSH_AUTH_SOCK" ]; then SSH="-v $SSH_AUTH_SOCK:$SSH_AUTH_SOCK -e SSH_AUTH_SOCK" fi docker run $SSH -it --privileged --rm -e TMUX_ENTRYPOINT=$TMUX $iid