Is that possibile use the docker in docker without mounting the Docker socket from host machine into the container using Ubuntu 22.04 base image

Hello Team,
I am able to use the docker in docker using ubuntu 22.04 base image and it is working fine while I run the docker image I am using this command (docker run -d -v /var/run/docker.sock:/var/run/docker.sock ) here I am mounting the Docker socket from the host machine into the container. Is that possibile use the docker in docker without mounting from the host machine into the container.

+++
FROM ubuntu:22.04
RUN apt-get update -y && apt-get install -y jq
RUN apt-get install -y apt-transport-https ca-certificates curl software-properties-common
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN add-apt-repository “deb [arch=amd64] Index of linux/ubuntu/ focal stable”
RUN apt-get update -y && apt-get install -y docker-ce
RUN bash service docker start
+++

Thanks

1 Like

Please take a look at the Dockerfile template of the official dind images and entrypoint script the image uses

You can not use service inside a container, because systemd is not available. Furthermore, what you use right now can only be docker on docker (as in docker cli inside a container to control the docker engine it is running on). DinD does not require the docker.sock from the host to be mounted, DonD does.

Yes meyay I know the docker DIND method where we can use this Docker:dind image to run without mounting docker.sock from local.

I want to use this image to run on kubernetes cluster. so I dont want to use privilaged mode for this image

But I want to use ubuntu:22.04 base image for some further projects and i want to run docker inside my image which has base image of ubuntu 22.04 and some dependencies. I dont want to attach the docker.sock from my host machine.

I tried lot of ways to achieve this. is this possible to use the Base image as ubuntu 22.04 and without attaching the docker socker from the host. Also I dont want to use the Docker:dind base image as well.

1 Like

Though, you did understand that my comment was about: take a look how they solved it, learn from it and adopt it?

Since dind has the sole purpose of building images, have you considered to use a specialized tool for that task? Kaniko, Buildah and Buildkit do the job just fine.