I have been successful building an image for a simple python script that is part of the working directory as follows:
My DockerFile
looks as below:
# Using Python runtime 3.10
FROM python:3.10
# Set the working directory of the container
WORKDIR /src
# Copy the project directory to the container
COPY . /src/
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Command to run the application
CMD [ "python", "./anonymizer/app/main.py" ]
I then build the image successfully -
PS C:\Python Test> docker build -t anonymizer -f DockerFile .
And when I run the image interactively -
PS C:\Python Test> docker run -it anonymizer /bin/bash
It seems to have run successfully too
However, the python script didn't seem to have run as the files the script were meant to create never got written into the data/*
folders as below. On the contrary, when I run the same script as defined in CMD
variable of DockerFile
from the container, the files do get created as shown in the screenshot below.
Why isn't the CMD running the Python script?