systemctl

 

$ dockerUnit=$(systemctl show -p FragmentPath docker.service | cut -d "=" -f 2)
$ unitFile=${dockerUnit:-/etc/systemd/system/docker.service.d/kata-containers.conf}
$ test -e "$unitFile" || { sudo mkdir -p "$(dirname $unitFile)"; echo -e "[Service]\nType=simple\nExecStart=\nExecStart=/usr/bin/dockerd -D --default-runtime runc" | sudo tee "$unitFile"; }
$ grep -q "kata-runtime=" $unitFile || sudo sed -i 's!^\(ExecStart=[^$].*$\)!\1 --add-runtime kata-runtime=/usr/local/bin/kata-runtime!g' "$unitFile"
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

 

 systemd单元文件放置位置:

/usr/lib/systemd/system/systemd默认单元文件安装目录

/run/systemd/systemsystemdsystemd单元运行时创建,这个目录优先于按照目录

/etc/systemd/system系统管理员创建和管理的单元目录,优先级最高。
 systemctl list-unit-files --type service
  systemctl cat docker
 root@pcl-01:/etc/systemd/system# systemctl list-unit-files | grep docker     
docker.service                                                   enabled        
docker.socket                                                    enabled        
root@pcl-01:/etc/systemd/system# 

 

posted on 2020-10-20 17:02  tycoon3  阅读(197)  评论(0编辑  收藏  举报

导航