1
votes

Dockerfile :

...
VOLUME [ “/sys/fs/cgroup” ]
CMD ["/usr/sbin/init"]

I build & run my centos7 docker container on Centos7.

$ docker run --privileged -ti -d -e "container=docker" --name centos7-server -v /sys/fs/cgroup:/sys/fs/cgroup centos7:81ee535 /usr/sbin/init

after, input below commend

$ docker stop centos7-server

.. forever loop..

if /usr/sbin/init to /bin/bash, centos7-server be stoped(success) well.

but, I want to use systemd in centos7-server container..

What can cause the problem ?

1

1 Answers

0
votes

The sbin/init program (also called init) coordinates the rest of the boot process and configures the environment for the user.

Using CentOS docker, init always executes before CMD / ENTRYPOINT. So, it has no sense to use init as COMMAND or ENTRYPOINT.

Definitively, don't worry about init. Don't launch it with docker run nor docker exec, because it's going to be executed anyway. The init program starts all of the background processes by looking in the appropriate rc directory for the runlevel specified as the default in /etc/inittab. The rc directories are numbered to correspond to the runlevel they represent. For instance, /etc/rc.d/rc5.d/ is the directory for runlevel 5. So, it has no sense to stop it unless you shutdown system.