29

I thought this was pretty straightforward to make docker daemon not to start when I start my machine, but seems not to be the case. I installed docker manually and then used the following simple line post installation:

sudo systemctl disable docker

But to my surprise this did not do much and I could still see the daemon happily running around!

joesan@joesan-InfinityBook-S-14-v5:~$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
joesan@joesan-InfinityBook-S-14-v5:~$ 

Is there anything that I'm missing? Any clues?

4 Answers 4

47

This works for me (18.04):

$ sudo systemctl disable docker.service
$ sudo systemctl disable docker.socket

You can run:

$ systemctl list-unit-files | grep -i docker

To check the docker services and disable them manually in the same way $sudo systemctl disable <service-name>.

1
  • 2
    According to the documentation containerd.service should also be disabled and not only docker.service. They don't mention docker.socket although I disabled all three.
    – Daniel
    Commented Oct 18, 2023 at 18:08
11

in ubuntu Ubuntu 20.04.1 LTS

after

$sudo systemctl disable docker.service
$sudo systemctl disable docker.socket
$ systemctl list-unit-files | grep -i 'state\|docker'
UNIT FILE                                  STATE           VENDOR PRESET
alsa-state.service                         static          enabled      
docker.service                             disabled        enabled      
docker.socket                              disabled        enabled 

As pointed out by others you need:

sudo systemctl restart docker

to have docker not working in the current session, check it with :

sudo systemctl docker
1
  • Is it enough just to sudo systemctl stop docker? and not restart Commented Jun 7 at 17:12
5

disable will not stop the process by itself, it just won't start it the next time. You need to either restart your machine or type

sudo systemctl stop docker

to stop the process.

4
  • 2
    OP says prevent docker autostart. Disable would be needed in that case, right? Stop (as the name suggests) would only stop the process.
    – Parth Shah
    Commented Jul 17, 2020 at 20:41
  • 1
    Yes. You need to disable the service to prevent the autostart Commented Jul 17, 2020 at 20:42
  • I just restarted my machine and I can see that dockerd is started after a restart which is what I want to avoid. Your post does not help!
    – joesan
    Commented Jul 17, 2020 at 20:42
  • 2
    run systemctl status docker. What do you see? Commented Jul 17, 2020 at 20:42
3

Check docker services running

systemctl list-unit-files | grep -i docker

Check the task names, usually docker.service and docker.socket on my system Ubuntu 20.04.5 LTS they are named this way.

Prevent docker from starting using the listed docker tasks

sudo systemctl disable docker.service
sudo systemctl disable docker.socket

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