简体   繁体   中英

python: can't open file '//ML_project.py': [Errno 2] No such file or directory in Docker

Here is the content in my Dockerfile. I am trying to containerise a python script (ML_project.py).

FROM continuumio/miniconda3:latest

COPY ML_Project.py .

RUN pip install fxcmpy

CMD ["python", "ML_project.py"]

My dockerfile and ML_project.py lies within the same folder (fxcm_project)

C:\Users\Jack\PycharmProjects\fxcm_project

How do I set my current working directory and docker run the file?

When you docker build , you create a container which embeds all stuffs specified in the Dockerfile.

If during the execution a local resource cannot be found, then it is most likely that the ressource is not wothin the container or you passed a wrong location.

In your case, you might be looking for the WORKDIR dockerfile command: WORKDIR.

NOTE: During the debug phase, feel free to edit your Dockerfile in order to get more (precise) pieces of information. For instance, you could change the last line to print out the current working directory and list all the files it contains. The associated commands are respectively pwd and ls -la .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM