I built API using FastAPI that calls some bash commands. Now I want to make a docker container for my app but I encountered the following issue: if I create a docker container, the app won't run bash commands. I guess I need to get out of docker container to run bash commands but I am not sure that it is possible. Any suggestions? Apologies in advance if my question is confusing. Here is my Docker File
FROM python:3.9
WORKDIR /code
COPY ./requirements.txt /code/requirements.txt
RUN pip3 install --no-cache-dir --upgrade -r /code/requirements.txt
COPY ./app /code/app
# CMD ["python", "./app/main.py"]
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
and here is an example of how I run bash command (it is actually a docker command)
@app.post("/stop-camera")
async def stop_camera(info: Request):
req_info = await info.json()
file_name = str(req_info["id"])
result1 = subprocess.run([str(env_dictionary["STOP"])+ file_name], shell = True)
result2 = subprocess.run([str(env_dictionary["REMOVE"])+ file_name], shell = True)
return {
"status" : "SUCCESS",
"stop" : result1,
"rm" : result2
}