Ébe Isaac
Ébe Isaac

Reputation: 12391

How to stop Docker (and Kubernetes) using Docker desktop?

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?

Upvotes: 44

Views: 86592

Answers (7)

valdeci
valdeci

Reputation: 15265

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

Maybe you will need to use the Force Quit option.

enter image description here

Upvotes: 31

xpt
xpt

Reputation: 23074

This is the official way:

enter image description here

Works for me with

ProductName:        macOS
ProductVersion:     14.1.2
BuildVersion:       23B92

checked with ps (only thing left is docker.vmnetd):

$ ps -eaf | grep -i docker
    0   517     1   0 18Dec23 ??         0:00.33 /Library/PrivilegedHelperTools/com.docker.vmnetd
  501 28284 17445   0 12:28pm ttys000    0:00.00 grep -i docker

Upvotes: 3

Hannes Stoolmann
Hannes Stoolmann

Reputation: 906

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.)

Upvotes: 78

Abdullah Ismail
Abdullah Ismail

Reputation: 465

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

Upvotes: 5

ssilk
ssilk

Reputation: 51

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).

Upvotes: 2

hoanghuychh
hoanghuychh

Reputation: 135

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

ex my process kill -9 71397 enter image description here

Upvotes: 0

h4xnoodle
h4xnoodle

Reputation: 1128

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.

Upvotes: 2

Related Questions