FROM python:alpine3.7 COPY . /app WORKDIR /app RUN pip install -r requirements.txt # Write Flask in this file EXPOSE 5001 ENTRYPOINT [ "python" ] CMD [ "app.py" ]
Here is what the above code is Doing:
1. We are using the python:alpine3.7 image as our base image.
2. We are copying the current directory to /app in the image.
3. We are setting the working directory to /app.
4. We are installing the required Python packages.
5. We are exposing port 5001.
6. We are telling Docker that the container will run the python app.py command when it starts.