What is docker mask and how to unmask docker service?

Masking a service prevents the service from being started manually or automatically, which is a stronger version of disable .Masking disable all symlinks of the specified unit file are removed.

Example :

root@opensource:~# sudo service docker restart
Failed to restart docker.service: Unit docker.service is masked.
root@opensource:~# docker –version
Docker version 19.03.5, build 78d1802

In case of  Sysctl Masking shows the same output :

root@opensource:~# sudo systemctl enable docker
Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker
Failed to enable unit: Unit file /etc/systemd/system/docker.service is masked.

We can to unmask the docker service like below

root@opensource:~# systemctl unmask docker.service
Removed /etc/systemd/system/docker.service.
root@opensource:~# systemctl unmask docker.socket
root@opensource:~# systemctl start docker.service

Now docker and docker service will be working as usual

root@opensource:~$ systemctl list-unit-files | grep docker
docker.service                                        enabled        
docker.socket                                         enabled  
root@opensource:~$  docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                    PORTS               NAMES

Leave a Reply

Your email address will not be published.