This is a reference implementation of running Docker in your Docker-ized Jenkins build agent(s)
$ docker build -t YOUR_IMAGE_TAG .
$ docker run -d --privileged \
--rm --name=dind_agent \
-p NEW_PORT:22 \
-e "JENKINS_AGENT_SSH_PUBKEY=[YOUR_PUBLIC_KEY]" YOUR_IMAGE_TAG
Please note, due to the nature of Docker in Docker, you MUST run the container with the --privileged
parameter.