1

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.

Following is my code from Dockerfile

 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

Following is my python code

 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")

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I am sorry but your instructions are not working as intended.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.