Last active
November 8, 2022 08:22
-
-
Save loopmode/4d59a4e9a0a2ffacaec2dd14db4ae8bd to your computer and use it in GitHub Desktop.
dockerized ubuntu shell
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
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.