├── Dockerfile ├── README.md └── docker-compose.yml /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM jenkins/jenkins:lts-jdk17 2 | USER root 3 | RUN apt-get update && apt-get install -y lsb-release 4 | RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc \ 5 | https://download.docker.com/linux/debian/gpg 6 | RUN echo "deb [arch=$(dpkg --print-architecture) \ 7 | signed-by=/usr/share/keyrings/docker-archive-keyring.asc] \ 8 | https://download.docker.com/linux/debian \ 9 | $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list 10 | RUN apt-get update && apt-get install -y docker-ce-cli 11 | USER jenkins -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Install Jenkins using Docker Compose 2 | 3 | This repository contains a Docker Compose configuration for a quick installation of Jenkins. This setup is not intended for production systems. 4 | 5 | Credits: This approach is mostly based on the [offical instructions](https://www.jenkins.io/doc/book/installing/docker/) but takes advantage of Docker Compose (by using a `docker-compose.yml` file) to reduce the number of steps needed to get Jenkins up and running. 6 | 7 | # Docker Installation 8 | 9 | ## Step 1 10 | 11 | Install Docker locally (probably using Docker Desktop is the easiest approach). 12 | 13 | ## Step 2 14 | 15 | Clone this repository or download it's contents. 16 | 17 | ## Step 2 18 | 19 | Open a terminal window in the same directory where the `Dockerfile` from this repository is located. Build the Jenkins Docker image: 20 | 21 | ``` 22 | docker build -t my-jenkins . 23 | ``` 24 | 25 | ## Step 3 26 | 27 | Start Jenkins: 28 | 29 | ``` 30 | docker compose up -d 31 | ``` 32 | 33 | ## Step 4 34 | 35 | Open Jenkins by going to: [http://localhost:8080/](http://localhost:8080/) and finish the installation process. 36 | 37 | ## Step 5 38 | 39 | If you wish to stop Jenkins and get back to it later, run: 40 | 41 | ``` 42 | docker compose down 43 | ``` 44 | 45 | If you wish to start Jenkins again later, just run the same comand from Step 3. 46 | 47 | 48 | # Removing Jenkins 49 | 50 | Once you are done playing with Jenkins maybe it is time to clean things up. 51 | 52 | Run the following comand to terminate Jenkins and to remove all volumes and images used: 53 | 54 | ``` 55 | docker compose down --volumes --rmi all 56 | ``` 57 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | jenkins-docker: 3 | image: docker:dind 4 | container_name: jenkins-docker 5 | privileged: true 6 | environment: 7 | - DOCKER_TLS_CERTDIR=/certs 8 | volumes: 9 | - jenkins-docker-certs:/certs/client 10 | - jenkins-data:/var/jenkins_home 11 | ports: 12 | - "2376:2376" 13 | networks: 14 | jenkins: 15 | aliases: 16 | - docker 17 | command: --storage-driver overlay2 18 | 19 | my-jenkins: 20 | image: my-jenkins 21 | build: 22 | context: . 23 | container_name: my-jenkins 24 | restart: on-failure 25 | environment: 26 | - DOCKER_HOST=tcp://docker:2376 27 | - DOCKER_CERT_PATH=/certs/client 28 | - DOCKER_TLS_VERIFY=1 29 | volumes: 30 | - jenkins-data:/var/jenkins_home 31 | - jenkins-docker-certs:/certs/client:ro 32 | ports: 33 | - "8080:8080" 34 | - "50000:50000" 35 | networks: 36 | - jenkins 37 | 38 | networks: 39 | jenkins: 40 | driver: bridge 41 | 42 | volumes: 43 | jenkins-docker-certs: 44 | jenkins-data: --------------------------------------------------------------------------------