Friday, May 8, 2020

Install Jenkins Master using Docker | Install Jenkins using Docker | Install Jenkins using Docker-Compose

Jenkins is a popular continuous integration tool. It can be installed quickly using Docker with less manual steps.

How to setup Jenkins using Docker and Docker compose

8080 is opened security firewall rules

Install Docker
sudo apt-get install -y

Install Docker-Compose
sudo apt-get install docker-compose -y 

Add Docker group to user 
sudo usermod -aG docker $USER

Now logout and login again.

Create docker-compose.yml
sudo vi docker-compose.yml

version: '3.1'
        container_name: jenkins
            - '8080:8080'
            - '50000:50000'
        image: jenkins/jenkins:lts
        restart: always
            - 'JENKINS_URL=http://jenkins:8080'
            - /var/run/docker.sock:/var/run/docker.sock  # Expose the docker daemon in the container
            - /home/jenkins:/home/jenkins # Avoid mysql volume mount issue
Save the file by entering :wq!
Now execute the compose file using Docker compose command:
docker-compose up -d

If you are getting any errors like this, make sure you execute below commands to adding Docker group to current user.

sudo usermod -aG docker $USER

Make sure Jenkins is up and running
sudo docker-compose logs

Once you see the message, that's it. Jenkins has been installed successfully.
Now access Jenkins UI by going to browser and enter public dns name with port 8080
Now to go to browser --> http://your_Jenkins_publicdns_name:8080
You can copy the password from above command.

No comments:

Post a Comment