34

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?

5
  • 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, 2020 at 8:12
  • see this qa and the resulting issue
    – Matt
    Nov 12, 2020 at 8: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, 2021 at 2: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). Sep 15, 2022 at 6: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 at 8:00

5 Answers 5

53

The docker desktop app starts a qemu vm, so the desktop app has no control over the PIDs. To oversome 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.)

7
  • 3
    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, 2021 at 2: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" ;-) Aug 21, 2021 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" ! Sep 2, 2021 at 13:22
  • @HannesStoolmann There is no "ship" symbol? Docker Desktop 4.2.0 (70708)
    – endo64
    Nov 16, 2021 at 21:57
  • 2
    There is. It depends on the OSX version. It depends where you place the panel ;-) Nov 26, 2021 at 10:56
21

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

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, 2021 at 19:25
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.

1
  • Quitting appears to kill the daemon after a few seconds; just not right away.
    – TrueWill
    Jul 29, 2021 at 14:24
0

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

ex my process kill -9 71397 enter image description here

3
  • 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, 2022 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 Nov 21, 2022 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 at 7: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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.