0

I am using docker binaries on RHEL7 where daemon started using

dockerd &

I also need to do some configuration for which I need to stpr start the docker but I have to kill the process and finding no way out to stop the docker daemon.

I have tried:

$ sudo service docker stop

but it says:

Redirecting to /bin/systemctl stop docker.service
Failed to stop docker.service: Unit docker.service not loaded

I can access my container. I need to find out graceful way of stopping and starting docker rather than kill the process. please help.

Martin Evans
  • 45,791
  • 17
  • 81
  • 97
ali
  • 11
  • 3

2 Answers2

0

If you want to use "systemctl" on the host system then make sure that a service descriptor does exist. So after installation of docker, do "systemctl daemon-reload" and check the result of "systemctl cat docker.service".

Guido U. Draheim
  • 3,038
  • 1
  • 20
  • 19
-1

if you go to docker hub of centos7 release you are using there is instruction on how to run the centos with systemctl enabled.In 552 short:

Create a dockerfile and paste:
FROM centos:7
MAINTAINER “you” your@email.here
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in ; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done);
rm -f /lib/systemd/system/multi-user.target.wants/;
rm -f /etc/systemd/system/.wants/;
rm -f /lib/systemd/system/local-fs.target.wants/;
rm -f /lib/systemd/system/sockets.target.wants/udev;
rm -f /lib/systemd/system/sockets.target.wants/initctl;
rm -f /lib/systemd/system/basic.target.wants/;
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ “/sys/fs/cgroup” ]
CMD ["/usr/sbin/init"]

Then build the container using in the dir you have created the file (be sure no other files are inside, as they will be taken into the context and may cause troubles :wink: )

docker build --rm -t c7-systemd . (c7-systemd can be replaced with other name)

Then run the image with:
docker run -itd --privileged --name=yourName c7-systemd