Linux Commands

How to Start Docker Using systemctl Command

After installing Docker, a daemon is created to manage it on the host operating system. The docker daemon, commonly referred to as dockerd, is responsible for managing docker images, containers, and other services.

As with other services, the systemctl can also be used to manage the dockerd service. The systemctl is a command line utility used to manage the systemd services in Linux distributions that come with systemd init system.

In this guide, I will demonstrate the process of managing the Docker service on Linux by utilizing the systemctl tool.

How to Start Docker Service Using systemctl Command

By default, on Linux, the docker service initiates upon boot. However, in many cases, you may want to manage it manually, such as troubleshooting it, or in case of abnormality. Docker service and socket files can easily be managed with the systemctl. The command to start the docker service is given below:

sudo systemctl start docker.service

The above command will not produce any indication that the service has begun functioning. To determine if the Docker service is active and running, use the status option with the systemctl command and the service name.

sudo systemctl status docker

Note that, in the above commands, the .service extension is optional and can be skipped.

How to Manage Docker Boot Settings using systemctl Command

As mentioned earlier, in all modern Linux distributions, the docker service starts automatically on boot. But in order to manage it manually, the systemctl command can be employed.

For example, if you want to reduce boot time and save resources by not starting the docker service on boot, simply disable it.

sudo systemctl disable docker

Disabling the docker service will not immediately stop it; the service will remain active until explicitly stopped. The service will remain active, however, the target file that keeps the service enabled on boot will be removed and on the next boot the service will be disabled.

To start the docker, simply use the systemctl start with the service name, and to stop it, use the systemctl stop commands.

sudo systemctl stop docker

And to start it on boot, enable the service.

sudo systemctl enable docker

Enabling the service will again create a symbolic link in the /wants directory.

How to Start Docker Service Manually

If you do not want to use the systemctl command line utility to start the docker service, then it can be manually triggered using the dockerd command with sudo privileges.

sudo dockerd

To stop the service, press ctrl+c keys.

Conclusion

The system administration tool is also capable of handling the Docker service on Linux. By default, the docker service is enabled on boot, however, it can also be managed manually using the systemctl command. To start an inactive docker service the systemctl start docker command is used and to disable it to load on boot the systemctl disable docker command is used.

About the author

Sam U

I am a professional graphics designer with over 6 years of experience. Currently doing research in virtual reality, augmented reality and mixed reality.
I hardly watch movies but love to read tech related books and articles.