【问题标题】:How to run daemon in centos container which can not use `systemctl` nor `service`?如何在不能使用`systemctl`和`service`的centos容器中运行守护进程?
【发布时间】:2021-08-25 07:35:13
【问题描述】:

在我的 centos8.2 docker 实例中,我将chrony 安装为NTP client,但无法运行:

[root@7338cdd80407 src]# /usr/sbin/chronyd -f  /etc/chrony.conf 
adjtimex(0x8001) failed : Operation not permitted
[root@7338cdd80407 src]# service
bash: service: command not found
[root@7338cdd80407 src]# /usr/sbin/chronyd 
adjtimex(0x8001) failed : Operation not permitted

众所周知,在centos 容器中不能使用systemctlservice 来运行守护进程。那么在这种情况下如何运行呢?

【问题讨论】:

    标签: docker centos containers


    【解决方案1】:

    根本原因是您在新建容器时错过了SYS_TIME 功能。

    接下来是works命令:

    $ docker run --rm -it --cap-add SYS_TIME centos:8 /bin/bash
    [root@5598c5147823 /]# /usr/sbin/chronyd -f  /etc/chrony.conf
    [root@5598c5147823 /]# ps aux | grep chronyd
    chrony     124  0.1  0.0  97140  2556 ?        S    09:45   0:00 /usr/sbin/chronyd -f /etc/chrony.conf
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-05
      • 1970-01-01
      • 2023-03-02
      • 1970-01-01
      • 1970-01-01
      • 2016-02-14
      • 2014-04-12
      • 2019-03-29
      相关资源
      最近更新 更多