Untitled
# Create project directory mkdir my-python-app cd my-python-app # app.py import sys def main(args): for arg in args: print(f'Argument received: {arg}') if __name__ == "__main__": main(sys.argv[1:]) # Use an official Python runtime as a parent image FROM python:3.9-slim # Set the working directory in the container WORKDIR /usr/src/app # Copy the current directory contents into the container at /usr/src/app COPY . . # Run app.py when the container launches CMD ["python", "./app.py"] # Build Docker image docker build -t my-python-app . # Run Docker container with arguments docker run my-python-app arg1 arg2 arg3
Leave a Comment