The following will start the container in the background with ports 8080 and 50000 mapped from the host to the container. The first volume allows the docker client on the container to access the docker server on the host. The second volume will be used to run the docker install script.
docker run -d -p 8080:8080 -p 50000:50000 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v scriptvol:/scripts \
--name jenkins jenkins/jenkins:lts
curl -o install-docker.sh https://gist.githubusercontent.com/toddboyd/df2340021e7f6dce1ead2b8c9a8517d5/raw/bd6731f36ac5592572235e27359d85103b002067/install-docker.sh
View file here: install-docker.sh
Copy the install-docker.sh script to the scriptvol volume that was created when the container was started.
sudo cp install-docker.sh /var/lib/docker/volumes/scriptvol/_data
Exec into the container
docker exec -it -u root jenkins bash
Run the docker install script
sh /scripts/install-docker.sh
Test the installation
docker version
Add the jenkins user to the docker group
usermod -a -G docker jenkins