0

I have shell script which contains multiple python scripts (which are run one after another and not in parallel).I need to know how can I dockerize this?

This is My shell script(this takes in one argument of path) -

#!/bin/bash
#parameter from shell
parameter_directory="$1"
# Python script 1
python script1.py --outpath $parameter_directory

# Python script 2
python script2.py $parameter_directory 

# Python script 3
python script3.py $parameter_directory

#Python script 4
python script4.py $parameter_directory

#Python script 5
python script5.py $parameter_directory

#Python script 6
python script6.py $parameter_directory 
Nikhil Bhat
  • 23
  • 1
  • 3
  • 1
    Can you please edit your question and add an example shell script that's similar to yours? Please use formatting options and don't post code as a screenshot. – Oresztesz Sep 05 '18 at 13:15
  • @Oresztesz Hi, Have edited the question.Hope it'll help to answer the question.These python scripts are Machine Learning scripts which are run one after the other. – Nikhil Bhat Sep 06 '18 at 00:39

1 Answers1

2

You have to create a folder which has all your files plus your shell script. Let's say the shell script is named as entrypoint.sh. The directory will look like the following:

Dockerfile
entrypoint.sh
script1.py
script2.py
script3.py
script4.py
script5.py
script6.py

Notice, that there's a Dockerfile which will contain the following information:

FROM python:2-slim
WORKDIR /app
ADD . /app
ENTRYPOINT ["./entrypoint.sh"]

Build your docker image using the following command:

docker build -t python-sandbox .

Finally, run your created image in a container using the following command:

docker run -ti --rm --volume parameter_directory:/parameter_directory python-sandbox /parameter_directory

Be aware that Windows and Mac have some limitations when it comes to mounting volumes.

Docker: Sharing a volume on Windows with Docker Toolbox

Oresztesz
  • 2,294
  • 1
  • 15
  • 26