2. Jenkins Setup

2.1. Installing on Docker

  1. Set-up environment:

    $ mkdir -p /home/jenkins
    $ chmod 777 /home/jenkins
    $ chmod 777 /var/run/docker.sock
    
  2. Run Docker container:

    $ docker run \
        --detach  \
        --name jenkins \
        --rm \
        --publish 8080:8080 \
        --volume /home/jenkins:/var/jenkins_home \
        --volume /var/run/docker.sock:/var/run/docker.sock \
        jenkins/jenkins
    
  3. Get admin password:

    $ cat /home/jenkins/secrets/initialAdminPassword
    

2.2. Installing using Docker Compose

  1. Create /home/jenkins.yaml:

    Listing 31. jenkins.yaml
    version: '3'
    
    networks:
        ecosystem:
            driver: bridge
    
    services:
        jenkins:
            image: jenkins/jenkins
            container_name: jenkins
            restart: "no"
            ports:
                - "8100:8080"
            networks:
                - ecosystem
            volumes:
                - /home/jenkins:/var/jenkins_home/
                - /var/run/docker.sock:/var/run/docker.sock
    
  2. Run Jenkins

    $ cd /home/
    $ docker-compose -f jenkins.yaml up -d