I’m facing an issue while building a Docker image using a Dockerfile. I have a directory named “shatranj” that contains two Python files (chessmain.py
and chessengine.py
) and several PNG files. The goal is to include these files in the Docker image and run the chess game within a container.
However, when I execute the docker build
command with the Dockerfile, I encounter the following error message:
Step 3/5 : COPY shatranj /app/
COPY failed: file not found in build context or excluded by .dockerignore: stat shatranj: file does not exist
I have verified the following:
- Directory structure: The “shatranj” directory is located in the same directory as the Dockerfile, and it contains all the necessary files (
chessmain.py
,chessengine.py
, and PNG files). - Build context: I am executing the
docker build
command from the correct directory, which includes both the Dockerfile and the “shatranj” directory. - .dockerignore file: I don’t have a .dockerignore file in the build context, so there shouldn’t be any files excluded.
Here’s an excerpt from my Dockerfile:
FROM python:3.9
WORKDIR /app
COPY shatranj /app/
RUN pip install pygame
CMD [“python”, “shatranj/chessmain.py”]
I have tried modifying the COPY command to include the relative path from the build context (COPY ../shatranj /app/
), but the issue persists.