When starting the Docker service in Linux, the error message `failed to start docker.service: unit docker.service is masked` is encountered. Solution to the startup failure

If you encounter the error message `failed to start docker.service: unit docker.service is masked` when starting the Docker service in Linux, it means that the Docker service has been disabled by the system.

In Linux systems, you can use the `systemctl` command to manage system services. If a service is disabled, the service's `systemd` unit file will be marked as "masked". Services marked "masked" cannot be started and cannot be unmarked with the `systemctl unmask` command.

If you want to enable the Docker service, you can use the following command:

```
sudo systemctl unmask docker.service
sudo systemctl unmask docker.socket
sudo systemctl start docker.service
```

The first command cancels the mark of `docker.service`, the second command cancels the mark of `docker.socket`, and the third command starts the Docker service.

If the above method still cannot solve the problem, you can try to reinstall the Docker service. Docker can be completely removed before reinstalling using the following command:

```
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
``Then reinstall Docker:

```
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
```

The above is how to reinstall Docker on an Ubuntu system. If you are using another Linux distribution, please refer to the official documentation of that distribution.

Guess you like

Origin blog.csdn.net/pitymouse/article/details/130954635