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.

47 lines
1.2 KiB

  1. #!/bin/bash
  2. if [[ $1 == "help" ]]; then
  3. echo "lc (Launch Container) help:
  4. ===========================
  5. - lc new <dockerfile> <container_name> <image_name>: create new image &
  6. container using the selected dockerfile
  7. - available dockerfiles: go, rust
  8. - lc stop <container_name>: stop container
  9. - lc rm <container_name>: remove container
  10. - lc ls: list containers
  11. - lc stop <container_name> <image_name>: stop container
  12. - lc <container_name>: launch container
  13. "
  14. exit 0
  15. elif [[ $1 == "new" ]]; then
  16. # $2: lang, $3: container_name, $4: image_name
  17. if [[ $2 == "rust" ]]; then
  18. 2="Dockerfile.rust"
  19. elif [[ $2 == "go" ]]; then
  20. 2="Dockerfile.go"
  21. else
  22. echo "available dockerfiles: go, rust"
  23. exit 0
  24. fi
  25. sudo docker build -t $4 -f $2 .
  26. sudo docker run -it --entrypoint=/bin/bash --name $3 $4
  27. exit 0
  28. elif [[ $1 == "stop" ]]; then
  29. # $2: container_name
  30. sudo docker stop $2
  31. exit 0
  32. elif [[ $1 == "rm" ]]; then
  33. # $2: container_name
  34. sudo docker stop $2
  35. sudo docker rm $2
  36. exit 0
  37. elif [[ $1 == "ls" ]]; then
  38. sudo docker ps -a
  39. exit 0
  40. fi
  41. # $1: container_name, $2: image_name
  42. sudo docker start $1
  43. sudo docker container exec -it $1 bash