Last active
October 1, 2019 09:08
-
-
Save riccardobl/f40358b1fa15386f49c01938c7f72d55 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################################ | |
# Usage: | |
# vos ubuntu:18.04 bash | |
############################################################ | |
# Simple script that starts a podman/docker container | |
# mounts the current dir, run a command as the current user | |
# and destroy itself when the terminal is closed | |
############################################################ | |
userUID=`id -u` | |
groupUID=`id -g` | |
RUN_AS="-u=$userUID:$groupUID" | |
CMD="" | |
if [ "$2" = "" ]; | |
then | |
CMD="bash"; | |
fi | |
if [ "$XARGS" = "" ]; | |
then | |
export XARGS="" | |
fi | |
if [ "$ROOT" != "" ]; | |
then | |
export RUN_AS="" | |
fi | |
if [ "$DOCKER_IN_DOCKER" != "" ]; | |
then | |
export XARGS="$XARGS -v /var/run/docker.sock:/var/run/docker.sock" | |
fi | |
RUNTIME="sudo docker" | |
if [ "`which podman`" != "" ]; | |
then | |
RUNTIME="podman" | |
fi | |
echo $RUNTIME run $XARGS -v"$PWD:$PWD" $RUN_AS -w $PWD --rm -it $@ $CMD | |
$RUNTIME run $XARGS -v"$PWD:$PWD" $RUN_AS -w $PWD --rm -it $@ $CMD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment