0

I am trying to run docker inside my container. I saw in some of the article that I need to pass --privileged=true to make this possible.

But for some reason, I do not have the option to pass this parameter while running.. because it is been taken care by some automation which I do not have access.

So, I was wondering if its possible to pass above option in Dockerfile, so that I do not have the pass this as param.

Right now this is the content of my dockerfile.

FROM my-repo/jenkinsci/jnlp-slave:2.62

USER root
#RUN --privileged=true this doesnt work for obvious reasons
MAINTAINER RD_TOOLS "abc@example.com"
RUN apt-get update
RUN apt-get remove docker docker-engine docker.io || echo "No worries"
RUN apt-get --assume-yes install \
     apt-transport-https \
     ca-certificates \
     curl \
     gnupg2 \
     software-properties-common curl
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN apt-key fingerprint 0EBFCD88
RUN cat /etc/*-release
RUN apt-get --assume-yes install docker.io
RUN docker --version
RUN service docker start

WIthout passing privilaged= true param, it seems I cant run the docker inside docker.

Any help in this regard is highly appreciated.

kaounKaoun
  • 601
  • 1
  • 9
  • 21
  • Why do you need to dind engine running at build time of the Jenkins slave? – BMitch Jul 05 '18 at 10:55
  • This answer could also be useful: https://stackoverflow.com/a/33003273/9521610 – VAS Jul 05 '18 at 15:56
  • Possible duplicate of [Is it ok to run docker from inside docker?](https://stackoverflow.com/questions/27879713/is-it-ok-to-run-docker-from-inside-docker) – N8888 Mar 28 '19 at 13:49

1 Answers1

1

You can't force a container to run as privileged from within the Dockerfile.

As a general rule, you can't run Docker inside a Docker container; the more typical setup is to share the host's Docker socket. There's an official Docker image that attempts this at https://hub.docker.com/_/docker/ with some fairly prominent suggestions to not actually use it.

David Maze
  • 130,717
  • 29
  • 175
  • 215