前言

使用docker搭建服务环境,拉取了一个Centos7镜像,在镜像中使用systemctl命令启动sladpd服务,已经使用--privileged=true启用特权模式,但还是报错。

docker 启动命令如下:

docker run -itd --name=ldap --privileged=true -v  \ 
-p 80:80 -p 389:389 centos:7 /usr/sbin/init

错误信息

● 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.

解决方法:

挂载宿主机cgroup目录,启动时加上-v /sys/fs/cgroup:/sys/fs/cgroup

完整启动命令如下:

docker run -itd --name=ldap --privileged=true \
-v /sys/fs/cgroup:/sys/fs/cgroup \ 
-p 80:80 -p 389:389 centos:7 /usr/sbin/init
在docker的centos镜像中使用systemctl启动slapd服务报错
Tagged on:

发表评论

电子邮件地址不会被公开。 必填项已用*标注