I have a running python executable EIA.py which extracts information from EIA.gov website and downloads necessary information into an excel file on my laptop's C:/Python Folder. However, when I convert this file into image and run using docker run command for image it gives me following error.
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Python/Sid.xls'
I am not adding any file but Python should rather create an excel file with contents extracted from website.
FROM python
VOLUME ["C:/Sid"]
WORKDIR /app
COPY . /app
RUN pip install EIA-python
RUN pip install requests
RUN pip install pandas
RUN pip install xlwt
RUN python /app/EIA.py
import eia
import pandas as pd
api_key = "mykey"
api = eia.API(api_key)
series_storage = api.data_by_series(series='NG.NW2_EPG0_SWO_R48_BCF.W')
df1 = pd.DataFrame(series_storage)
df1.reset_index(inplace=True)
df1.columns = ['Date', 'Value']
df1['Date'] = pd.to_datetime(df1['Date'].str[:-3], format='%Y %m%d')
df1.to_excel("C:/Python/Sid.xls")
Docker containers do not have persistent storage. To save a file locally from a container, you can either bind a folder mount or create a docker volume. Docker volumes are the preferred mechanism for persisting data as they are completely managed within Docker CLI itself. Check out here for more info.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.