Start docker service after container start?


I have a need to start the docker service in the container. Unfortunately I can not run the docker service when the container starts.

Tell me, what am I doing wrong? In my dockerfile I wrote.

FROM jenkins/jenkins:lts

USER root
RUN apt-get update \
      && apt-get install -y sudo \
      && apt-get -y install apt-transport-https ca-certificates curl gnupg2 software-properties-common nano wget vim \
      && curl -fsSL$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey \
      && add-apt-repository "deb [arch=amd64]$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable" \
      && apt-get update \
      && apt-get -y install docker-ce \
      && rm -rf /var/lib/apt/lists/*

CMD service docker start
ENTRYPOINT service docker start

The container simply does not start. I start it later manually.
Why CMD or ENTRYPOINT does not work?

So in this line:

(1) Assuming it worked, the service command would immediately return, and when it did, the main command the container ran would be finished, and so the container would exit.

(2) In any case, commands like service or systemctl depend on a heavy-weight daemon that most containers don’t run and that requires extended privileges to manage things on the host.

(3) And in any case, you generally can’t run Docker inside a Docker container.

The Installing Jenkins documentation has some hints on how to do this better.

@dmaze Thanks for the reply.

1,2 I understood.

3 - Yes, I know what to do, but I can not do it. Kubernetes something is capricious.
And to that, I then go into the container and calmly start the docker. It works in a container.