Skip to content

Instantly share code, notes, and snippets.

@toddboyd
Last active December 2, 2018 18:06
Show Gist options
  • Save toddboyd/5ee29ba54cc6ffcf42eb27dace6450da to your computer and use it in GitHub Desktop.
Save toddboyd/5ee29ba54cc6ffcf42eb27dace6450da to your computer and use it in GitHub Desktop.
Setup jenkins docker image that can create docker images

Setup Jenkins Docker image that can create Docker images

Start the container

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

Download the Docker install script

curl -o install-docker.sh https://gist.githubusercontent.com/toddboyd/df2340021e7f6dce1ead2b8c9a8517d5/raw/bd6731f36ac5592572235e27359d85103b002067/install-docker.sh

View file here: install-docker.sh

Copy the Docker install script to the Docker volume

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 running container and run the docker install script

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment