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:
- 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.
- 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:
- 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:
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:
- 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:
While on the dashboard, you will notice something in the lower-left part of the screen: