37

I'm running Docker Desktop for MacOS and I don't know how to stop the Docker service. It runs all the time using up the MacBook battery.

On a simple search, there are docs showing how to stop the containers but not the docker service itself.

I might be missing something obvious, but is there a way to stop both Kubernetes and Docker service without having to kill the desktop app?

Ébe Isaac
  • 11,563
  • 17
  • 64
  • 97
  • 1
    Not that I'm aware of, the app and the docker vm are linked. You can disable the kubernetes instance in the options. – Matt Nov 12 '20 at 08:12
  • see this [qa](https://stackoverflow.com/q/42637339/1318694) and the [resulting issue](https://github.com/docker/for-mac/issues/4388) – Matt Nov 12 '20 at 08:17
  • Everyone should look at Hannes Stoolmann's answer below for a working resolution to the issue. At least it worked for me on MacOS Mojave, to be accurate. – jmdeamer Aug 15 '21 at 02:17
  • Why would you leave docker desktop running when you can restart it any time? imo it is of no use when the docker vm is not running, therefore Quit Docker Desktop is ok (still imo). – Remigius Stalder Sep 15 '22 at 06:46
  • It didn't work for me too and I found this question here. After some time I noticed the Docker icon has tooltip "Docker is stopping". All in all it took about 10 minutes for it to quit but it did. – havryliuk Jan 12 '23 at 08:00

6 Answers6

65

The docker desktop app starts a qemu vm, so the desktop app has no control over the PIDs. To overcome the "situation" do the following:

  • open the Terminal app

  • edit the file ~/.bash_profile

  • add the following lines

    #macro to kill the docker desktop app and the VM (excluding vmnetd -> it's a service)
    function kdo() {
      ps ax|grep -i docker|egrep -iv 'grep|com.docker.vmnetd'|awk '{print $1}'|xargs kill
    }
  • save the file

Quit the terminal app and open it again.

Type kdo to kill all the dependend apps (hypervisor, docker daemon etc.)

  • 4
    This worked! After all this time of the mighty Docker team acting like it was impossible to do anything about the issue. Hannes "first week on Stack Overflow" Stoolmann comes along and resolves it. I'll have to dive into what's going on in that function but THANKS! – jmdeamer Aug 15 '21 at 02:11
  • 2
    @jmdeamer. No prob. The desktop app starts the VM as child process, so it should be quite easy to send a SIGNAL "down the road" ;-) – Hannes Stoolmann Aug 21 '21 at 15:36
  • 11
    As of today's latest version you can stop DOCKER Desktop App by clicking the "ship" symbol in the top panel and then hit "Quit Docker Desktop" ! – Hannes Stoolmann Sep 02 '21 at 13:22
  • @HannesStoolmann There is no "ship" symbol? Docker Desktop 4.2.0 (70708) – endo64 Nov 16 '21 at 21:57
  • 2
    There is. It depends on the OSX version. It depends where you place the panel ;-) – Hannes Stoolmann Nov 26 '21 at 10:56
  • If you don't have 'egrep' or get a warning, you can replace it with `grep -E` instead. Example: grep -iEv 'grep|com.docker.vmnetd' – EFreak Mar 29 '22 at 18:49
  • **Beware:** there's a bug preventing the Docker Desktop icon from appearing on MacOS. They have [an article on how to fix](https://www.docker.com/blog/new-docker-menu-improved-release-highlights-with-docker-desktop-4-5/). – Kamafeather Jul 07 '22 at 11:46
23

You can open the Activy Monitor, select Docker and then use the Quit button.

Maybe you will need to use the Force Quit option.

enter image description here

valdeci
  • 13,962
  • 6
  • 55
  • 80
  • 1
    Using quit/force quit on com.docker.backend just resulted in it automatically restarting on my machine. The only thing that actually terminated the process was the macro Hannes Stoolmann suggested as an answer. – jmdeamer Aug 22 '21 at 19:25
3

killall Docker # Kill all the docker related process in your MacOS

Abdullah Ismail
  • 415
  • 5
  • 6
2

I had been searching around for an answer to this too, as I noticed com.docker.hyperkit was taking >3GB memory and a lot of CPU, when the desktop app wasn't even opened on Mac OS X Catalina, Docker Desktop 3.0.4

Just as I was about kill -9, I noticed that quitting the docker app again actually did kill off every process except com.docker.vmnetd for whatever reason.

So I guess the solution here was... reopen and re-quit? I also made sure, of course, there were no running containers. I removed an old image too, unsure if that was related to it finally being able to fully quit.

h4xnoodle
  • 1,038
  • 1
  • 11
  • 14
0

com.docker.hyperkit taked > 8GB Memory . just run in terminal kill -9 PID

ex my process kill -9 71397 enter image description here

hoanghuychh
  • 127
  • 1
  • 4
  • 1
    Never use `kill -9` unless you have separately established that a regular `kill` will not work. You are preventing the process from cleaning up after itself properly. – tripleee Oct 28 '22 at 15:39
  • In this case, my docker process launched in the background, and I was forced to quit but docker was processing until I was forced to do so – hoanghuychh Nov 21 '22 at 16:33
  • There is always a way to kill a process, the problem is that the menu option Quit Docker Desktop does not do what it must. – havryliuk Jan 12 '23 at 07:52
0

Similar to Hannes example, but with alias: Create an .alias-file (in your home-dir) and add this line:

alias dockerstop="ps ax|grep -i docker|egrep -iv 'grep|com.docker.vmnetd'|awk '{print $1}'|xargs kill"

Make sure, the file is called during shell-startup (e.g. .profile, .bash_profile, .zprofile ...), like so:

source .aliases

After creating a new shell you can call the command dockerstop. The advantage of aliases over functions is (in my opinion), that you can easily list and filter them (e.g. alias | grep docker).

ssilk
  • 21
  • 2