-1

In opensuse docker container, cronjob is not working. When I try systemctl command getting this error: Failed to et D-bus: Unknown error -1 . I have tried many blogs and stackoverflow questions everywhere It was advised that basic architecture of Docker image should be redesigned.

What exactly needs to be done here is not mentioned. Kindly help, I am stuck on this issue.

  • personally I would avoid using cronjobs inside any container as the historic benefits of a cron are supplanted by the notion of a container itself ... if you need something container friendly I suggest using supervisord to be the parent of children processes launched inside a container – Scott Stensland Jul 09 '18 at 00:14

1 Answers1

0

To a first approximation, commands like systemctl, initctl, service, or start just don't work in Docker and you should find a different way to do what you're attempting.

Stylewise, the standard way to use a Docker container is to launch some sort of service in the foreground. As one specific example, the standard Redis image doesn't go through any sort of init script; it just runs

CMD ["redis-server"]

In most Docker images it's unusual to even so much as launch a background process (with the shell & operator). It's not usually necessary and in Dockerfiles the interaction with the RUN directive has confused some people.

In the specific case of systemctl, it requires an extremely heavyweight init system that is not just a process manager but also wants to monitor and manage kernel-level parameters, includes a logging system, runs an inter-process message bus, and some other functionality. You can't run systemd under Docker without the container being --privileged, which gives the container the ability to "escape" on to the host system in some unfortunate ways.

David Maze
  • 130,717
  • 29
  • 175
  • 215