skip to Main Content

I have a docker file like this which runs a hello-world FastAPI app.

FROM python:3.10.9-alpine3.16
RUN adduser -D app
USER app
WORKDIR /usr/src/app

COPY . .
RUN pip install --no-cache-dir -r requirement.txt

CMD [ "python", "./main.py" ]

I am running docker build and docker run command as :

docker build mytag/fastapi_web_app:latest .
docker run -p 8080:8080 mytag/fastapi_web_app:latest

and app works fine , but docker stop does not work on it,
whenever i try docker stop i get permission denied error, I even added my user to a new docker group as well , even if i repeat above step as a root user it does not work.
I am running Ubuntu 22.04.2 LTS a a virtual machine on windows.

I had to sh into the machine using docker exec command and then kill the process to stop the docker container , but this is not the right solution.
I should be able to stop docker container using docker stop command, even docker compose down does not work.

when I run docker stop this is the error I get:

Error response from daemon: Cannot kill container: <id>: permission denied

What am I missing here?

P.S. : Do not ask me to kill apparmor , i have other processes dependent on it and its just a workaround not a solution

2

Answers


  1. Have you tried running docker as root? (sudo prefix before the command)

    Login or Signup to reply.
  2. Try docker kill --signal=SIGTERM container_id

    This should enable you to terminate the process that is currently running within the container and terminate the container using the docker stop command.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search