Stopping the Docker Container

If you have been working with Docker up till this point, you need to make sure that you stop all containers to free up any ports that might be in use, especially port 8080, to allow Vagrant to work. To stop Docker containers from working, follow these steps:

  1. First, view the running containers by running docker ps.

From the output, we can see that the jenkinsci/blueocean image is running with a container ID of e84cdbec2a0c.

  1. Copy the container ID and pass it to the docker stop command as shown:

If we run docker ps again, we can see that there is no container running and the ports that were mapped are now freed:

Refer to the complete code at https://bit.ly/2utxZa4 and https://bit.ly/2Jre4xh.
  1. To spin up your environment, navigate to the Lesson6 folder in the repository on your terminal after cloning it to your PC. This is where files such as Vagrantfile, provision_master.sh, and provision_slave.sh are located. Inside this directory, run vagrant up:
The output generated by running vagrant up is a lot to capture, but if it displays the first few lines similar to the ones depicted in the preceding screenshot, you are off to a great start. Vagrant will basically pull the defined box image and run the steps outlined in the Vagrantfile that we discussed earlier. This includes assigning hostnames and IP addresses, port forwarding, and finally, running the provisioning scripts. You will also notice that the output is helpful enough.

Let this process run to completion until you get control of your terminal back. The final line of output before you get control of your terminal should look something similar to the following:

  1. To ensure that everything works as expected, run the vagrant status command on the same directory:

From the output, we can see that our three nodes are running, and these are master, node1, and node2. After verifying that our nodes are running, go to your browser and open the URL http://localhost:8080. You should be presented with the Jenkins Getting Started page as follows:

The page requires us to provide the default administrator password. To access this password, we will connect to the master node. On the same directory that you ran the previous vagrant commands, run vagrant ssh master. This, as you might have guessed, will connect to the master node:

This lands us in the terminal of the master node as the default Vagrant user. We want to display the default password in the /var/lib/jenkins/secrets/initialAdminPassword file, so run cat on this file as sudo to display the password:

Copy this over to the text field on your browser and continue with the setup. The setup process is similar to what we covered in the first chapter; thus it should be familiar to you. Complete the Jenkins setup, create an admin user, and log in to your installation.

While on the dashboard, you will notice something in the lower-left part of the screen: 

We talked about the build queue and build executors earlier in this section. This is where the status of both of these is displayed. When there is a build running, Jenkins displays on which executor it's running and if there are any builds waiting for the availability of an executor, they are displayed on Build Queue.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.98.71