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

Question:

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:UsersJackPycharmProjectsfxcm_project

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

Asked By: CountDOOKU

||

Answers:

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.

Answered By: Jib
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.