How to stop docker under Linux
Asked Answered
C

5

179

My version of OS Ubuntu 16.04. I want to stop docker, so I run in the terminal:

sudo systemctl stop docker

But this commands doesn't help me:

gridsim1103 ~: ps ax | grep docker 
11347 ?        Sl     0:00 containerd-shim 487e3784f983274131d37bde1641db657e76e41bdd056f43ef4ad5adc1bfc518 /var/run/docker/libcontainerd/487e3784f983274131d37bde1641db657e76e41bdd056f43ef4ad5adc1bfc518 runc
14299 pts/2    S+     0:00 grep --color=auto docker
29914 ?        S      0:00 sudo dockerd -H gridsim1103:2376
29915 ?        Sl     4:45 dockerd -H gridsim1103:2376
29922 ?        Ssl    0:24 containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim containerd-shim --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --runtime runc
30107 ?        Sl     1:01 /usr/bin/docker-proxy -proto tcp -host-ip 188.184.80.77 -host-port 8500 -container-ip 192.17.0.2 -container-port 8500
30139 ?        Sl     0:00 /usr/bin/docker-proxy -proto tcp -host-ip 188.184.80.77 -host-port 8400 -container-ip 192.17.0.2 -container-port 8400

Version of docker server is:

Server:
 Version:      1.12.1
 API version:  1.24 (minimum version )
 Go version:   go1.6.2
 Git commit:   23cf638
 Built:        Tue, 27 Sep 2016 12:25:38 +1300
 OS/Arch:      linux/amd64
 Experimental: false

I also unsuccessfully tried:

 sudo service docker stop
Cablegram answered 21/2, 2017 at 10:53 Comment(0)
L
123

The output of ps aux looks like you did not start docker through systemd/systemctl.

It looks like you started it with:

sudo dockerd -H gridsim1103:2376

When you try to stop it with systemctl, nothing should happen as the resulting dockerd process is not controlled by systemd. So the behavior you see is expected.

The correct way to start docker is to use systemd/systemctl:

systemctl enable docker
systemctl start docker

After this, docker should start on system start.

EDIT: As you already have the docker process running, simply kill it by pressing CTRL+C on the terminal you started it. Or send a kill signal to the process.

Lenticularis answered 21/2, 2017 at 11:17 Comment(0)
B
132

First I stop the docker by the following command:

sudo systemctl stop docker

Then I get the message :Warning: Stopping docker.service, but it can still be activated by: docker.socket. So, I stop the socket as well :

sudo systemctl stop docker.socket

Note: you can start and stop only the docker.socket when it triggers by it.

Brokenhearted answered 20/3, 2021 at 5:13 Comment(0)
L
123

The output of ps aux looks like you did not start docker through systemd/systemctl.

It looks like you started it with:

sudo dockerd -H gridsim1103:2376

When you try to stop it with systemctl, nothing should happen as the resulting dockerd process is not controlled by systemd. So the behavior you see is expected.

The correct way to start docker is to use systemd/systemctl:

systemctl enable docker
systemctl start docker

After this, docker should start on system start.

EDIT: As you already have the docker process running, simply kill it by pressing CTRL+C on the terminal you started it. Or send a kill signal to the process.

Lenticularis answered 21/2, 2017 at 11:17 Comment(0)
H
57

In my case, it was neither systemd nor a cron job, but it was snap. So I had to run:

sudo snap stop docker
sudo snap remove docker

... and the last command actually never ended, I don't know why: this snap thing is really a pain. So I also ran:

sudo apt purge snap

:-)

Heterogamy answered 20/8, 2019 at 7:14 Comment(3)
This is very useful, my dokerd process was taking 200% CPU but now it's more quiet now. Thanks!Bouffant
You may use sudo snap disable docker so docker won't start next time you boot. In this case, yo use docker you'd need to run sudo snap start dockerGiven
the last command is good for machines having HDD, lolTransposal
C
33

if you have no systemctl and started the docker daemon by:

sudo service docker start

you can stop it by:

sudo service docker stop
Configurationism answered 22/11, 2020 at 22:15 Comment(1)
after running the stop command I got this : Warning: Stopping docker.service, but it can still be activated by: docker.socket Brokenhearted
J
-10

stop docker:

docker stop docker_id

ex:

docker stop 1fec077018w4

remove docker:

docker rm docker_id

ex:

docker rm 1fec077018w4

do not to stop:

docker-compose kill -s SIGINT

docker restart:

docker-compose restart
Jiffy answered 6/12, 2021 at 14:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.