How to Disable the Ubuntu ‘Docker’ Service

The Container Runtime Daemon

In Ubuntu Linux, Docker has become the industry standard for containerized application deployment. When you install Docker, it sets up the docker.service (along with its socket, docker.socket) to run automatically in the background on boot. This daemon is responsible for managing all your containers, building images, and routing internal container network traffic to the outside world.

While this is essential if your server’s primary role is hosting microservices, it can be problematic if Docker is only used occasionally for local development or testing. The Docker daemon is notoriously heavy; it actively alters system firewall rules (iptables), consumes a noticeable amount of idle RAM, and maintains persistent network bridges. If you only spin up a Docker container once a month to test a specific script, leaving the daemon running 24/7 is a massive waste of resources and unnecessarily complicates your server’s network routing. You should disable it so it only runs when explicitly called.

How to Disable the Docker Service

Because Docker utilizes socket activation, you must disable both the primary service and the listening socket to prevent it from auto-starting.

Warning: Do not disable this if you host production containers or rely on Docker Compose stacks that must start on boot.

  1. Open your Ubuntu Terminal or connect via SSH.
  2. First, stop the active service and its socket:
sudo systemctl stop docker.service
sudo systemctl stop docker.socket
  1. Disable both so they do not attempt to start during the boot sequence:
sudo systemctl disable docker.service
sudo systemctl disable docker.socket
  1. If you want to absolutely ensure that no other user or script can accidentally spin up the Docker engine in the background, you can mask them:
sudo systemctl mask docker.service
sudo systemctl mask docker.socket

Your Ubuntu system is now completely free of Docker’s background network management and resource consumption. You will need to unmask and manually start the service the next time you wish to use containers.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.