Launch Jenkins and SonarQube Docker Containers
Lab Steps
Introduction
In this lab step, you will complete the provisioning of your Jenkins and SonarQube CICD environment. To do so, you will need to SSH into the cicd.platform.instance, and perform a git clone
 of the repository located on GitHub, at the following location https://github.com/cloudacademy/devops-jenkins-sonarqube.Â
Next, you will use the docker-compose
command to launch the Jenkins and SonarQube CICD docker containers. Two additional docker containers are launched to support the environment, Postgres and Socat. Postgres is the backend SQL database for SonarQube, and Socat provides a bi-directional TCP comms link for running "docker inside docker" - this is only required, for example, if the Jenkins docker container is configured to build docker containers itself, etc. With this completed, you will then use the docker client to query and inspect several environment values that are required for the remainder of this Lab. In particular, you will use it to query for the:
- Jenkins Initial Admin Password
Instructions
1. Use the git
 command to download the GitHub hosted DevOps Jenkins+SonarQube Integration repository:
Copy codegit clone https://github.com/cloudacademy/devops-jenkins-sonarqube.git cd ./devops-jenkins-sonarqube sudo yum install -y curl-devel
2. Query the initial local docker environment:
Copy codedocker info
3. Confirm that no docker containers currently exist:
Copy codedocker ps -aÂ
4. Ensure that you are currently in the devops-jenkins-sonarqube directory, and list the contents:
Copy codecd ~/devops-jenkins-sonarqube/ ls -lÂ
5. Examine the docker compose configuration within the docker-compose.yml file:
Copy codecat docker-compose.yml
6. Launch the Jenkins and SonarQube docker environment. Running these commands will grab the latest Jenkins docker image, and then launch the docker environment with logging enabled. The docker compose container provisioning process typically takes 1-2 minutes to complete. Upon conclusion four (4) docker containers will be launched Jenkins, SonarQube, Postgres, and Socat:
Copy codedocker pull jenkins/jenkins:lts docker-compose up -d && docker-compose logs -f
During the launching process, the Jenkins container will print out the initial admin password. This is required to complete the Jenkins installation process later on. You do not need to capture this as you will query for it in the following step after the full docker environment has been successfully provisioned:
Â
The full docker-compose
container launching process completes with a message stating that SonarQube is up:
7. Once the container provisioning process has completed successfully, exit the docker-compose
log tailing process by using the Ctrl+C key sequence. Ignore the Error: Aborting message. This is just the result of exiting the docker-compose
log tailing process:Â
Copy code![]()
8. Confirm that all docker containers are up and running. There should be four (4) docker containers in total: Jenkins, SonarQube, Postgres, and Socat:
Copy codedocker ps -a
9. Query for the Jenkins initial admin password. This will be required later to complete the Jenkins installation in the following Lab step. Make sure you copy-and-paste it somewhere, so you can later reference it:
Copy codedocker exec -it jenkins cat /var/jenkins_home/secrets/initialAdminPassword
Â
Â
Summary
In this Lab Step, you git cloned the devops-jenkins-sonarqube public GitHub repository. You then launched the Jenkins and SonarQube CICD docker environment. Finally, you queried for the Jenkins initial admin password, which you will use in a following Lab step to complete the Jenkins installation setup.
Â