Install Jenkins with Docker Compose

Install Jenkins with Docker Compose

Dockerhub Jenkins (opens in a new tab)

  1. Create docker-compose.yml

    docker-compose.yml
    version: '3.8'
    services:
      jenkins:
        image: jenkins/jenkins:jdk11
        restart: always
        privileged: true
        user: root
        ports:
          - '8081:8080'
          - '50000:5000'
        container_name: jenkins_jdk11
        volumes:
          - ~/Desktop/self-hosted/jenkins_home:/var/jenkins_home
          - /var/run/docker.sock:/var/run/docker.sock
    • You can map /var/jenkins_home to any local location you liked
  2. Start docker-compose.yml as background

    docker-compose up -d
  3. Verify Jenkins container service

    docker-compose ps
  4. Get the Jenkins admin password

    docker exec jenkins_jdk11 cat /var/jenkins_home/secrets/initialAdminPassword
  5. Open your browser, navigate to localhost:8081, and paste your password