I'm creating the image for Jenkins slave agent using inbound-agent:jdk11-1.0
base image and installed Docker. But Docker is not working and I'm getting ERROR: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/_ping": dial unix /var/run/docker.sock: connect: permission denied
.
Please find the docker file for the image.
FROM jenkins-test-image-1.0
USER root
RUN apt-get -y update && \
apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release \
software-properties-common
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
RUN apt-get -y update && \
apt-get -y install \
docker-ce \
docker-ce-cli \
containerd.io
RUN sudo usermod -aG docker jenkins
USER jenkins
Cans someone please help me.
I'm getting error for the Docker in Jenkins slave image.