I am attempting to put an existing python function into a docker container. The python code takes a CSV file (that will be in the same directory as the dockerfile) as input data and does some calculations. The py file looks like this and is named "PracticeDeploy.py":
import pandas as pd
import pickle
from OptimizationFunction import main_barrel
# Read in model
gbrModel = pickle.load(open('/src/ValDiffGBR.pkl', 'rb'))
file_name = str(input())
data=pd.read_csv('/src/'+file_name)
new_data = data.dropna(how='any')
preds = main_barrel(gbrModel, new_data)
Within my docker directory, I already have a subfolder which contains my first dockerfile with all libraries installed. Also in my directory, I have the py file, the CSV, and the model I import in the above py file. I am now trying to build another dockerfile that will take the CSV name as input and then run the python code.
Here is the dockerfile:
FROM [my repository] as builder
ARG DATA_FILE
RUN mkdir src
WORKDIR /src
COPY . /src
ENTRYPOINT ["PracticeDeploy.py"]
I build like this:
sudo docker build --rm -f Dockerfile -t "first_docker" --build-arg DATA_FILE='/src/[csv_name].csv' .
I attempt to run like this:
sudo docker run --rm first_docker
However I get this error:
docker: Error response from daemon: OCI runtime create
failed: container_linux.go:348: starting container process
caused "exec: \"PracticeDeploy.py\": executable file not
found in $PATH": unknown.
Should I only insert arguments when running? Am I approaching this correctly? I am very new to docker and am completely stumped.
ENTRYPOINT ["./PracticeDeploy.py"]should work.#!/usr/bin/env python.