Jenkins Dev Environment with docker-compose.

To read about the appcontainers/jenkins image and learn about all of the configurable options, check out the repository and read the readme.md.

appcontainers/jenkins CentOS 6.6 based Docker Hub Repository

1. Insure that docker/boot2docker and docker-compose are already installed on the server that you will pull the dev environment down to.

  • If your looking for additional information on installing Boot2Docker, then read the Tutorial on installing and running Boot2Docker
  • If your looking for additional information on installing docker-compose, then read the Tutorial on installing and running docker-compose
  • 2. Create a directory on the docker server or computer running boot2docker named whatever your application will be named.

    3. cd into that directory and create a file named docker-compose.yml. Copy the contents below into that file, modifying values for site names, desired ports, and passwords, and save it.

    CentOS 6.6 based version

    keydata:
      image: appcontainers/jenkins
      hostname: jenkins-keys
      stdin_open: true
      tty: true
      volumes:
      - /var/lib/jenkins_slave_key
      environment:
      - ROLE=slave
      - SSH_PASS=jenkinspassword
      command: /bin/bash  
    
    data:
      image: appcontainers/jenkins
      hostname: jenkins-data
      stdin_open: true
      tty: true
      volumes_from:
      - keydata
      volumes:
      - /var/lib/jenkins
      environment:
      - ROLE=slave
      - SSH_PASS=jenkinspassword
      command: /bin/bash
    
    dockerslave:
      image: appcontainers/jenkins
      hostname: docker-slave
      stdin_open: true
      tty: true
      restart: always
      privileged: true
      environment:
      - ROLE=slave
      - SSH_PASS=jenkinspassword
      volumes_from:
      - keydata
      volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      command: /bin/bash
    
    nodeslave:
      image: appcontainers/jenkins
      hostname: node-slave
      stdin_open: true
      tty: true
      restart: always
      privileged: true
      volumes_from:
      - keydata
      environment:
      - ROLE=slave
      - SSH_PASS=jenkinspassword
      command: /bin/bash
    
    mavenslave:
      image: appcontainers/jenkins
      hostname: maven-slave
      stdin_open: true
      tty: true
      restart: always
      privileged: true
      volumes_from:
      - keydata
      environment:
      - ROLE=slave
      - SSH_PASS=jenkinspassword
      command: /bin/bash
    
    web:
      image: appcontainers/jenkins
      hostname: jenkins
      stdin_open: true
      tty: true
      restart: always
      ports:
      - "8080:8080"
      environment:
      - ROLE=master
      - SSH_PASS=jenkinspassword
      volumes_from:
      - keydata
      - data
      links:
      - dockerslave
      - nodeslave
      - mavenslave
      command: /bin/bash

    4. run docker-compose up -d to pull down and start the development environment.

    5. Go to your boot2docker/docker ip :8080 in your browser, and enjoy your app!!

    Note that you this will spin up a container of the application in datavol mode, which will remove all packages but leave the application directory structure in tact. The application front end server will then be spun up connecting the /var/lib/jenkins directory to the persistent data container. This way you can wipe out the front end, spin up a fresh copy of it, and all of your config data and ssh key data will still be left in tact.

    0 comments