合 在docker中启动服务报错:New main PID 558 does not belong to service
在docker中启动服务报错: New main PID 558 does not belong to service, and PID file is not owned by root. Refusing.
前言
使用docker搭建服务环境,拉取了一个Centos7镜像,在镜像中使用 systemctl
命令启动 sladpd
服务,已经使用 --privileged=true
启用特权模式,但还是报错。
docker 启动命令如下:
1 2 | docker run -itd --name=ldap --privileged=true -v \ -p 80:80 -p 389:389 centos:7 /usr/sbin/init12 |
错误信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ● slapd.service - OpenLDAP Server Daemon Loaded: loaded (/usr/lib/systemd/system/slapd.service; disabled; vendor preset: disabled) Active: failed (Result: timeout) since Fri 2020-01-03 05:51:22 UTC; 2min 43s ago Docs: man:slapd man:slapd-config man:slapd-hdb man:slapd-mdb file:///usr/share/doc/openldap-servers/guide.html Jan 03 05:49:45 d5450c0c7b3e systemd[1]: Starting OpenLDAP Server Daemon... Jan 03 05:49:45 d5450c0c7b3e systemd[1]: New main PID 558 does not belong to service, and PID file is not owned by root. Refusing. Jan 03 05:49:45 d5450c0c7b3e systemd[1]: New main PID 558 does not belong to service, and PID file is not owned by root. Refusing. Jan 03 05:51:22 d5450c0c7b3e systemd[1]: slapd.service start operation timed out. Terminating. Jan 03 05:51:22 d5450c0c7b3e systemd[1]: Failed to start OpenLDAP Server Daemon. Jan 03 05:51:22 d5450c0c7b3e systemd[1]: Unit slapd.service entered failed state. Jan 03 05:51:22 d5450c0c7b3e systemd[1]: slapd.service failed.12345678910111213141516 |
解决方法:
挂载宿主机 cgroup
目录,启动时加上 -v /sys/fs/cgroup:/sys/fs/cgroup
完整启动命令如下: