0

I am new to docker and I exited the container's shell using exit and then used sudo docker stop ABC to kill the container. However, systemctl is-active docker still shows that docker is active. Is there any way to kill docker as well or would it remain active on my system forever?

I am using Ubuntu 18.

Black Jack 21
  • 315
  • 4
  • 19
  • 2
    Does this answer your question? [How to stop docker under Linux](https://stackoverflow.com/questions/42365336/how-to-stop-docker-under-linux) – Paolo Aug 29 '20 at 14:15

1 Answers1

3

Docker daemon is supposed to keep running in background even if you exit and remove the container. This is because in case if you want to start a new container and docker daemon is not running then you won't be able to do it.

In case if you want to, then you can do sudo systemctl stop docker to stop the docker daemon completely. But after this if you do docker run -it someimage then you'll get an error - and to fix that you'll have to restart the docker daemon - sudo systemctl start docker

Hope that clarifies everything!

vik-y
  • 449
  • 2
  • 5
  • 14
  • That does answer my question. Any reason why it is designed to keep running? I mean same can be said about notepad - we would need to ope it every time we want to edit a document but that does not mean we actually keep it running in background! – Black Jack 21 Aug 30 '20 at 12:41
  • 1
    Docker uses a client server model. Docker cli is the client and daemon is the server. Basically when you run a command like `docker run -it someimage` - the cli makes an api call to daemon running on your system to provision things for you. If the daemon was not running then it can't receive the api call and things won't work. So even if you have 0 containers running - the daemon needs to be up before you run any container. If you do not want to run any container at all - you can go ahead and stop it. :) – vik-y Aug 30 '20 at 21:16
  • Thank you for the explanation! – Black Jack 21 Aug 31 '20 at 15:38