I am creating a wrapper script to execute my python programs. The logic is like:
- I will install all my required modules in a docker container
- Pull the container and run the script, so anyone can run my scripts without worrying about the depended modules
- I created a wrapper script that will be called to execute the desired program
This is my wrapper script:
import os
import sys
import argparse
parse = argparse.ArgumentParser()
parse.add_argument('command', help="give datacenter name")
parse.add_argument('args', nargs=argparse.REMAINDER)
parse_arguments = parse.parse_args()
'''
Co-relate to the command and corresponding scripts to trigger
'''
scripts = {
'verify' : '/path/verify.py'
}
if __name__ == '__main__':
if parse_arguments.command not in scripts:
print('These are the available scripts to run:')
print('\n'.join(sorted(scripts.keys())))
else:
os.execv(scripts.get(parse_arguments.command),
[scripts.get(parse_arguments.command)] + parse_arguments.args) .
I am running this like,
$ docker run -it --rm --net host run-script verify --listenv tpc1
Traceback (most recent call last):
File "/path/runme.py", line 28, in <module>
os.execv(scripts.get(parse_arguments.command),
[scripts.get(parse_arguments.command)] + parse_arguments.args)
FileNotFoundError: [Errno 2] No such file or directory
My Docker image is run-script
If I run the same code from my local machine, it does work. but inside container it shows this file not find error.
Can anyone help me on this?