This is a reminder for myself, in case I forgot… which already happened several times….
FROM --platform=linux/amd64 python:3.9.15
WORKDIR /app
ADD . /app
RUN pip install -r requirements.txt
CMD ["gunicorn", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:80", "app.main:app"]
This is a Dockerfile example for running FastAPI application. Python version is 3.9.15
which needs to match your python version that set in your pyproject.toml
.
Otherwise, you may see the following error…
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "gunicorn": executable file not found in $PATH: unknown.
ERRO[0000] error waiting for container:
While doing port mapping, not matter in docker-compose
file or running with command docker run --name my_container -p 5566:80 my_image
The first port number is the port number for your machine.
The second port number is the port number for your container.
搶先發佈留言