0

I'm a bit new to docker and I have created images using docker-compose. But when I'm trying to stop or delete images it shows PermissionDenied, I even tried to do this using the root user but no effect. I have almost tried all methods and commands written on stack overflow. Also, I have tried to remove docker from the system, but it showed containers are running so can't remove docker. And nothing helped.

Can anyone tell me what can be the possible issue and how can I resolve this?

how can I delete those images?

Below are the commands and output that I have tried

shivam@flintrider:~$ docker ps
CONTAINER ID   IMAGE         COMMAND                  CREATED       STATUS                 PORTS      NAMES
dbd59e4554b0   postgres:13   "docker-entrypoint.s…"   3 weeks ago   Up 3 hours (healthy)   5432/tcp   airflow-postgres-1
shivam@flintrider:~$ docker image ls
REPOSITORY             TAG       IMAGE ID       CREATED       SIZE
airflow-airflow-init   latest    c84dcacd60e9   5 hours ago   1.45GB
postgres               13        2de938a8d18d   4 weeks ago   374MB
shivam@flintrider:~$ docker stop $(docker ps -q)
Error response from daemon: cannot stop container: dbd59e4554b0: permission denied
shivam@flintrider:~$ sudo docker stop $(docker ps -q)
[sudo] password for shivam: 
Error response from daemon: cannot stop container: dbd59e4554b0: permission denied
shivam@flintrider:~$ docker kill dbd59e4554b0
Error response from daemon: Cannot kill container: dbd59e4554b0: permission denied

If you need any other info, please let me know. I would appreciate any help.

Thanks :)

SHIVAM SINGH
  • 165
  • 2
  • 7
  • make sure to share actual command with the corresponding output that you tried. Actual error messages help a lot more to help you. – Rick Rackow Apr 20 '23 at 18:12
  • stop the containers before deleting – Anmol Parida Apr 20 '23 at 18:20
  • Sure updated. Also I have used `docker-compose stop` to stop the containers, but that also shows permission denied. – SHIVAM SINGH Apr 20 '23 at 18:27
  • @QOPS I have tried to stop the container. I don't want to delete docker actually. I just want to stop and remove these containers. – SHIVAM SINGH Apr 20 '23 at 18:28
  • You didn't mention your OS, nor whether you've tried the suggestions in answers to others with your question, eg: https://stackoverflow.com/questions/51729836/error-response-from-daemon-cannot-stop-container-signaling-init-process-cause, https://stackoverflow.com/questions/70434777/cannot-kill-container-container-id-tried-to-kill-container-but-did-not-rece Do you have Docker Desktop, and if so have you tried using it? – Don't Panic Apr 21 '23 at 05:23
  • Thanks The first link eventually worked. But still don't know why this happened. – SHIVAM SINGH Apr 21 '23 at 05:44
  • Glad you solved it. As it is a duplicate, let's close it as a duplicate. – Don't Panic Apr 21 '23 at 05:58
  • Yes @Don'tPanic I have mentioned that actual comment in the answer – SHIVAM SINGH Apr 21 '23 at 07:01

1 Answers1

0

restart docker and rerun the commands

sudo systemctl restart docker.service
Anmol Parida
  • 672
  • 5
  • 16