0

On Windows10 host creating the container based on centos:latest image:

# NB! the backticks is just PowerShell syntax to split long commands
docker run  --name='my_container' `
            --detach `
            --tty `
            centos `
            /usr/sbin/init

Then opening the container shell:

docker exec -it `
        my_container `
        /bin/bash

and running systemd:

# systemd
bash: systemd: command not found

Based on https://hub.docker.com/_/centos and other Google-ing results then the issue is that I should mount the host cgroup/systemd? Or am I misunderstanding something?

So this is not doable on Windows10 host?

user12761950
  • 139
  • 1
  • 2
  • 9
  • You probably shouldn't run systemd in Docker in any case: it tries to do a _lot_ of things that are inappropriate for a container. Can you avoid systemd and just run the single thing your container is trying to do as a foreground process? – David Maze Jul 03 '20 at 11:06
  • @DavidMaze, hi&thanks for replying. The initial thing I am trying to solve is to run cron service to schedule stuff in the container. Any other methods to achieve that? – user12761950 Jul 03 '20 at 11:11
  • Try to see if this works for your purposes > https://stackoverflow.com/a/37458519/1535270. If you really need to have a process manager, you should give a try to the following recommendations > https://docs.docker.com/config/containers/multi-service_container/ – abestrad Jul 03 '20 at 11:15
  • I'd start by reading questions like [How to run a cron job inside a docker container?](https://stackoverflow.com/q/37458287/10008173). It's okay and normal to have multiple containers in an application, so have a separate container to run scheduled tasks. – David Maze Jul 03 '20 at 11:31
  • abestrad and @DavidMaze thank you for your answers. It seems you are referencing the same article and yes it works with Ubuntu as guest. But the question is about CentOS quest. I don't seem to get cron working on that one, not able to start the service due to missing service manager. – user12761950 Jul 03 '20 at 13:37
  • You don't typically "start a service" in Docker. As the answers to that linked question suggest, you run things like cron daemons as the single foreground process in their respective containers. – David Maze Jul 03 '20 at 16:13
  • @DavidMaze thanks. Any hints/links "cron daemons as the single foreground process" how would I do this? – user12761950 Jul 06 '20 at 08:24

0 Answers0