1) Trying to run efg.py
script inside the container as an arg in the kubernetes deployment file.
2) Inside the container the file is present in /opt/abc/efg.py
.
3) While running the deployment it is showing no such file or directory.
4) These are the container spec:
spec: containers:
-name: abc
image: <full path here to the registry and image>
imagePullPolicy: Always
env:
- name: PYTHONPATH
value: "/opt"
args:
- /bin/sh
- -c
- cd /opt/abc && python3.6 efg.py
logs:
python3.6 :cant open the file : efg.py [errorno] no such file or directory exists.
The location of efg.py
in the container is /opt/abc/efg.py
.
Requirements:
1) Need to run the efg.py
.
2) egf.py
requires a log directory and a file to be created inside /opt/abc/
. Something like this /opt/abc/log/efg.log
.
a) either add mkdir in Dockerfile
("which is not working")
b) add it in the args
Posting @Nancy comments as community wiki answer to be more visible.
Solution:
1) Make the directory during docker image build
2) For running a script , give entry point in docker build or give it inside the deployment file in container specs as command:
In addition, if you need a env variable to be exported inside the pod you can give it inside the deployment file. There are other ways, but this worked for OP.