-
Notifications
You must be signed in to change notification settings - Fork 8
/
tryPython.sh
executable file
·33 lines (26 loc) · 1.46 KB
/
tryPython.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
###################################################
#### ---- Change this only if want to use your own
###################################################
ORGANIZATION=openkbs
###################################################
#### ---- Container package information ----
###################################################
DOCKER_IMAGE_REPO=`echo $(basename $PWD)|tr '[:upper:]' '[:lower:]'|tr "/: " "_" `
imageTag=${1:-"${ORGANIZATION}/${DOCKER_IMAGE_REPO}"}
echo
echo "----------------------------------------------------------------------"
echo "1.) Way-1: Run python3 with command line: Hello World (command line):"
docker run --rm ${imageTag} python3 -c 'print("Hello World (command line) from ./tryPython.sh")'
mkdir -p ./data
echo "print('Hello World (./data/myPyScript.py) from ./tryPython.sh')" > ./data/myPyScript.py
echo
echo "----------------------------------------------------------------------"
echo "2.) Way-2: Run python3 /data/myPyScript.py:"
echo "docker run --rm -v "$PWD"/data:/data --workdir /data ${imageTag} python3 myPyScript.py"
docker run --rm -v "$PWD"/data:/data --workdir /data ${imageTag} python3 myPyScript.py
echo
echo "----------------------------------------------------------------------"
echo "3.) Way-3: Pipe file host's current data directory ./data/myPyScript.py into python3:"
echo "docker run --rm --workdir /data ${imageTag} python3 < ./data/myPyScript.py"
docker run --rm --workdir /data ${imageTag} python3 < ./data/myPyScript.py