Showing posts with label Docker Compose. Show all posts
Showing posts with label Docker Compose. Show all posts

Monday, January 30, 2023

Install Artifactory using Docker Compose | Install Artifactory using Docker Compose on Ubuntu 22.0.4 | How to Setup JFrog Artifactory using Docker-Compose

How to setup Artifactory using Docker Compose?

Artifactory is open source, binary repository manager. Artifactory is the single solution for managing all the artifacts, binaries, files and containers throughout your software supply chain. 

Some of the key features of Artifactory:
  • Supports 27 different package types including helm charts, docker images regardless of tech stack.
  • A single source of truth for all your binaries
  • Integration with all CICD tools
  • role based authorization with teams to manage artifacts 
  • you can create local, remote and virtual repositories
What is Docker Compose?
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. Since Docker Compose lets you configure related containers in a single YAML file, you get the same Infrastructure-as-Code abilities as Kubernetes. But they come in a simpler system that’s more suited to smaller applications that don’t need Kubernetes’ resiliency and scaling.
 
The purpose of docker-compose is to function as docker cli but to issue multiple commands much more quickly. To make use of docker-compose, you need to encode the commands you were running before into a docker-compose.yml file
 
Run docker-compose up and Compose starts and runs your entire app.

Watch the Steps in YouTube channel:

Pre-requisites:
  • Ubuntu EC2 up and running with at least t2.medium (4GB RAM), 2GB will not work
  • Port 8081, 8082 is opened in security firewall rule
  • instance should have docker-compose installed

Change Host Name to Artifactory
sudo hostnamectl set-hostname Artifactory

Perform System update
sudo apt update

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

Create docker-compose.yml
this yml has all the configuration for installing Artifactory on Ubuntu EC2.
sudo vi docker-compose.yml 

(Copy the below code high-lighted in yellow color)
version: "3.3"
services:
  artifactory-service:
    image: docker.bintray.io/jfrog/artifactory-oss:7.49.6
    container_name: artifactory
    restart: always
    networks:
      - ci_net
    ports:
      - 8081:8081
      - 8082:8082
    volumes:
      - artifactory:/var/opt/jfrog/artifactory

volumes:
  artifactory:
networks:
  ci_net:

Save the file by entering :wq!

Now execute the compose file using Docker compose command to start Artifactory Container
sudo docker-compose up -d 

-d means detached mode

Make sure Artifactory is up and running
sudo docker-compose logs --follow


Once you see the message, that's it. Artifactory is been setup successfully. Now press Control C and enter to come out of the above screen.

Check Artifactory is up and running by typing below command:
curl localhost:8081
This confirms that Artifactory is up and running locally.

How to access Artifactory in the browser?
Now access Artifactory UI by going to browser and enter public dns name with port 8081
http://change to_artifactory_publicdns_name:8081

default user name is admin
password is password


After Login, click on Get started. 

Now reset admin password. enter new admin password 

Skip for base URL and skip proxy setup
Click Next, click on Finish




How to integrate Artifactory with Jenkins?

How to stop Artifactory container
sudo docker-compose down




Saturday, March 19, 2022

Install Jenkins on Ubuntu 22.0.4 using Docker Compose | Setup Jenkins on AWS EC2 Ubuntu instance | How to setup Jenkins in Ubuntu EC2 instance using Docker?

Please follow the steps to install Jenkins using Docker compose on Ubuntu 22.0.4 instance. 

What is Docker Compose?
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
 
The purpose of docker-compose is to function as docker cli but to issue multiple commands much more quickly. To make use of docker-compose, you need to encode the commands you were running before into a docker-compose.yml file
 
Run docker-compose up and Compose starts and runs your entire app.

Change Host Name to Jenkins
sudo hostname Jenkins

Perform update first
sudo apt update

Now lets start Docker. compose installation first:

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

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

Create directory
mkdir ~/jenkins

Jenkins Setup

Create docker-compose.yml
this yml has all configuration for installing Jenkins
sudo vi docker-compose.yml 

version: '3.3'
services:
  jenkins:
    image: jenkins/jenkins:lts
    restart: unless-stopped
    privileged: true
    user: root
    ports:
      - 8080:8080
    container_name: jenkins
    volumes:
      - ~/jenkins:/var/jenkins_home
      - /var/run/docker.sock:/var/run/docker.sock
      - /usr/local/bin/docker:/usr/local/bin/docker

Now execute the compose file using Docker compose command:
sudo docker-compose up -d 



Make sure Jenkins is up and running
sudo docker-compose logs --follow
You can also get the admin password


How to get Jenkins admin password in another way?
Identify Docker container name

sudo docker ps


Get admin password by executing below command
sudo docker exec -it jenkins cat /var/jenkins_home/secrets/initialAdminPassword


Access Jenkins in web browser

Now Go to AWS console. Click on EC2, click on running instances link. Select the checkbox of EC2 you installed Jenkins. Click on Action. Copy the value from step 4 that says --> Connect to your instance using its Public DNS:

Now go to browser. enter public dns name or public IP address with port no 8080.

Unlock Jenkins
You may get screen, enter the below command in Git bash( Ubuntu console)

Copy the password and paste in the browser.
Then click on install suggested plug-ins. 
Also create user name and password.
enter everything as admin. at least user name as admin password as admin
Click on Save and Finish. Click on start using Jenkins. Now you should see a screen like below:



That's it. You have setup Jenkins successfully using Docker compose. 
Please watch the steps in our YouTube channel.

Tuesday, January 11, 2022

Install SonaType Nexus 3 using Docker Compose | Install SonaType Nexus 3 using Docker on Ubuntu 22.0.4 | Install Nexus 3 using Docker-Compose

How to setup SonaType Nexus 3 using Docker compose?

Nexus is open source, binary repository manager and Java based tool. It can be installed quickly using Docker with less manual steps.

What is Docker Compose?
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. Since Docker Compose lets you configure related containers in a single YAML file, you get the same Infrastructure-as-Code abilities as Kubernetes. But they come in a simpler system that’s more suited to smaller applications that don’t need Kubernetes’ resiliency and scaling.
 
The purpose of docker-compose is to function as docker cli but to issue multiple commands much more quickly. To make use of docker-compose, you need to encode the commands you were running before into a docker-compose.yml file
 
Run docker-compose up to run the entire app.

Watch Steps in YouTube channel:

Pre-requisites:

  • Ubuntu EC2 up and running with at least t2.medium(4GB RAM), 2GB will not work
  • Port 8081, 8085 is opened in security firewall rule
  • instance should have docker and docker-compose installed

Change Host Name to Nexus
sudo hostnamectl set-hostname Nexus

Perform System update
sudo apt update

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

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

Create docker-compose.yml
this yml has all the configuration for installing Nexus on Ubuntu EC2.
sudo vi docker-compose.yml 

(Copy the below code high-lighted in yellow color)
version: "3"
services:
  nexus:
    image: sonatype/nexus3
    restart: always
    volumes:
      - "nexus-data:/sonatype-work"
    ports:
      - "8081:8081"
      - "8085:8085"
volumes:
  nexus-data: {}

Save the file by entering :wq!

Now execute the compose file using Docker compose command to start Nexus Container
sudo docker-compose up -d 


-d means detached mode

Make sure Nexus 3 is up and running
sudo docker-compose logs --follow


Once you see the message, that's it. Nexus 3 is been setup successfully. Now press Control C and enter to come out of the above screen.

How to get Nexus admin password?
Now access Nexus UI by going to browser and enter public dns name with port 8081
Now to go to browser --> http://change to_nexus_publicdns_name:8081

We need to login to Nexus docker container to get Nexus admin password.

Identify Docker container name
sudo docker ps


Get admin password by executing below command
sudo docker exec -it ubuntu_nexus_1 cat /nexus-data/admin.password


Please follow below steps for integrating Nexus 3 with Jenkins

Monday, December 20, 2021

Install SonarQube using Docker | Install SonarQube using Docker on Ubuntu 22.0.4 | Install SonarQube using Docker-Compose

How to setup SonarQube using Docker compose?

SonarQube is static code analysis tool. It is open source and Java based tool. SonarQube can be setup using Docker Compose with less manual steps.

What is Docker Compose?
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. Since Docker Compose lets you configure related containers in a single YAML file, you get the same Infrastructure-as-Code abilities as Kubernetes. But they come in a simpler system that’s more suited to smaller applications that don’t need Kubernetes’ resiliency and scaling.
 
The purpose of docker-compose is to function as docker cli but to issue multiple commands much more quickly. To make use of docker-compose, you need to encode the commands you were running before into a docker-compose.yml file
 
Run docker-compose up and Compose starts and runs your entire app.

SonarQube Architecture



SonarQube have three components namely
1. Scanner - This contains scanner and analyser to scan application code.
2. SonarQube server - contains Webserver(UI) and search server 
3. DB server - used for storing the analysis reports.

Watch steps in YouTube channel:


Pre-requisites:

  • New Ubuntu 22.0.4 EC2 instance with at least t2.medium (4 GB RAM)
  • Port 9000 is opened in security firewall rule
  • Make sure below is taken care off.

Login to SonarQube EC2 instance using git bash or iTerm, perform below command to configure virtual memory permanently for SonarQube to function:
sudo nano /etc/sysctl.conf

Add the following lines to the bottom of that file by scrolling all the way down:

vm.max_map_count=262144
fs.file-max=65536

Press Ctrl + O and Enter for saving the file.

Press Ctrl + X for exiting the file after saving.

To make sure changes are getting into effect:
sudo sysctl -p

Change Host Name to SonarQube
sudo hostnamectl set-hostname SonarQube

Perform System update
sudo apt update

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

Create docker-compose.yml
this yml has all configuration for installing both SonarQube and Postgresql:
sudo vi docker-compose.yml 

(press I or insert button and then Copy the below code high-lighted in yellow color)
version: "3"
services:
  sonarqube:
    image: sonarqube:community
    restart: unless-stopped
    depends_on:
      - db
    environment:
      SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
      SONAR_JDBC_USERNAME: sonar
      SONAR_JDBC_PASSWORD: sonar
    volumes:
      - sonarqube_data:/opt/sonarqube/data
      - sonarqube_extensions:/opt/sonarqube/extensions
      - sonarqube_logs:/opt/sonarqube/logs
    ports:
      - "9000:9000"
  db:
    image: postgres:12
    restart: unless-stopped
    environment:
      POSTGRES_USER: sonar
      POSTGRES_PASSWORD: sonar
    volumes:
      - postgresql:/var/lib/postgresql
      - postgresql_data:/var/lib/postgresql/data
volumes:
  sonarqube_data:
  sonarqube_extensions:
  sonarqube_logs:
  postgresql:
  postgresql_data:

Press escape button and then 
Save the file by entering :wq!

Now execute the compose file using Docker compose command:
sudo docker-compose up -d 


Make sure SonarQube is up and running by checking the logs
sudo docker-compose logs --follow


Once you see the message, that's it. SonarQube is been installed successfully. press control C and enter.
Now access sonarQube UI by going to browser and enter public dns name with port 9000

Please follow steps for integrating SonarQube with Jenkins
https://www.coachdevops.com/2020/04/how-to-integrate-sonarqube-with-jenkins.html

Master DevSecOps and Multi Cloud Computing Course by Coach AK | DevSecOps and Cloud Computing Online Classes | Sep 2025 Schedule

  Master DevSecOps and cloud Computing Bootcamp Schedule for Sep 2025 Are you ready to  supercharge your career  in  DevSecOps ? Whether you...