Skip to content

Instantly share code, notes, and snippets.

@loopmode
Last active November 8, 2022 08:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loopmode/4d59a4e9a0a2ffacaec2dd14db4ae8bd to your computer and use it in GitHub Desktop.
Save loopmode/4d59a4e9a0a2ffacaec2dd14db4ae8bd to your computer and use it in GitHub Desktop.
dockerized ubuntu shell
dockerized-ubuntu() { dockerized ubuntu ubuntu:latest /bin/bash bash }
dockerized-curl() { dockerized curl pstauffer/curl:latest /bin/sh sh }
# based on https://stackoverflow.com/a/56690087/368254
dockerized()
{
name=$1
image=$2
containercmd=$3
runcmd=$4
dir=~/.dockerized-$name
mkdir -p $dir
cd $dir
cat << EOF > ./docker-compose.yml
version: "3.7"
services:
$name:
image: $image
command: $containercmd
tty: true
EOF
printf "Now entering the container...\n"
docker-compose run $name $runcmd
docker-compose down
rm -rf $dir
}
@loopmode
Copy link
Author

loopmode commented Aug 29, 2019

gif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment