Jump to content

How to Start Docker Using systemctl Command


Recommended Posts

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

word-image-413643-1.png

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

word-image-413643-2.png

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.

word-image-413643-3.png

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

word-image-413643-4.png

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

word-image-413643-5.png

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.

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...