0

Unable to start services inside docker container using service command.

By passing privileged mode when starting container, service command works. But i don't want to pass privileged mode when starting container.

Please let me know, is there any way to resolve this issue?

Tanjila
  • 47
  • 1
  • 8
  • do you run the container with a user which is not root? – LinPy Jun 25 '19 at 12:53
  • Broadly, you should assume the `service` command (and related commands like `systemctl`) just don’t work inside Docker. Typically you’d run only one process in a Docker container, and you don’t need any sort of `service` type wrapper; your image’s CMD would just launch it as a foreground process. – David Maze Jun 25 '19 at 15:58
  • @LinSel - I am running container as a root user only – Tanjila Jun 28 '19 at 05:22
  • @DavidMaze - u mean to say we can't run any service command inside docker container? – Tanjila Jun 28 '19 at 05:23

1 Answers1

0

this is a duplicate of below ticket. use below command to solve your issue.

docker run -d -it --privileged ContainerId /usr/sbin/init

use docker file from below link for fix this issue. when run the docker image use --privileged.

https://hub.docker.com/_/centos

duplicate

  • 1
    There is a new location for official Docker image for centos, avoid, as possible the centos images from the Docker Hub, the new site it is located in here: [https://quay.io/repository/centos/centos?tab=tags&tag=latest](https://quay.io/repository/centos/centos?tab=tags&tag=latest) – Franco Gil Apr 04 '23 at 18:06