How to run daemon in centos container which can not use `systemctl` nor `service`?

Viewed 882

In my centos8.2 docker instance, I installed chrony as NTP client, but I can not run it:

[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

as we all know in centos container there can not use systemctl nor service to run a daemon. so how to run it in this case?

1 Answers

The root cause is you miss SYS_TIME capability when new your container.

The works command is next:

$ 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
Related