I am trying to save a figure to my local after I build and run my docker file. My docker File is this
FROM python:3.7
WORKDIR /usr/src/app
# copy all the files to the container
COPY . .
RUN mkdir -p /root/.config/matplotlib
RUN echo "backend : Agg" > /root/.config/matplotlib/matplotlibrc
RUN pip install pandas matplotlib==2.2.4
CMD ["python", "./main.py"]
My main.py is this
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
data = pd.read_csv('data/coding-environment-exercise.csv')
st_name=data['student']
marks=data['mark']
x=list(st_name)
y=list(marks)
print(x)
out_path = '/output/your_filename.png'
plt.plot(x,y)
plt.savefig("test2.png",format="png")
However after I run this docker file via these commands I can't find the png. It tried my code in local python ide. It saves the figure however I couldn't do it via docker.
docker build -t plot:docker .
docker run -it plot:docker