You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

51 lines
1.2 KiB

#!/bin/bash
path=${0::-3}
if [[ $1 == "help" ]]; then
echo "lc (Launch Container) help:
===========================
- lc new <dockerfile> <container_name> <image_name>: create new image &
container using the selected dockerfile
- available dockerfiles: go, rust
- lc stop <container_name>: stop container
- lc rm <container_name>: remove container
- lc ls: list containers
- lc stop <container_name> <image_name>: stop container
- lc <container_name>: launch container
"
exit 0
elif [[ $1 == "new" ]]; then
# $2: lang, $3: container_name, $4: image_name
lang=$2
if [[ $lang == "rust" ]]; then
lang="$path/Dockerfile.rust"
elif [[ $lang == "go" ]]; then
lang="$path/Dockerfile.go"
else
echo "available dockerfiles: go, rust"
exit 0
fi
echo $lang
sudo docker build -t $4 -f $lang $path/.
sudo docker run -it --entrypoint=/bin/bash --name $3 $4
exit 0
elif [[ $1 == "stop" ]]; then
# $2: container_name
sudo docker stop $2
exit 0
elif [[ $1 == "rm" ]]; then
# $2: container_name
sudo docker stop $2
sudo docker rm $2
exit 0
elif [[ $1 == "ls" ]]; then
sudo docker ps -a
exit 0
fi
# $1: container_name, $2: image_name
sudo docker start $1
sudo docker container exec -it $1 bash