๐ #๐๐ฎ๐๐ฎ๐ฏ - Jenkins Freestyle Project for DevOps Engineers | #๐ต๐ฌ๐๐ฎ๐๐๐ข๐ณ๐๐ฒ๐๐ข๐ฝ๐
DevOps | Cloud Practitioner | AWS | GIT | Kubernetes | Terraform | ArgoCD | Gitlab
Completing Tasks with Jenkins and Docker Integration ๐
Hereโs a step-by-step guide to complete the above tasks and integrate Jenkins with Docker for building and running containers efficiently.
Task 1: Build and Run a Docker Container in a Jenkins Freestyle Project
Step 1: Create a Jenkins Agent
Install and configure a Jenkins agent on the system where Docker is installed.
Make sure Docker is accessible by the Jenkins user.
Step 2: Create a Freestyle Project
Open Jenkins and click on "New Item".
Enter the project name (e.g., "Docker-Build-Run") and select Freestyle Project.
Click OK to create the project.
Step 3: Configure Build Steps
Step 1: Build the Docker Image
In the Build section, add an "Execute Shell" build step with the following command:docker build -t your-app-image:latest .Step 2: Run the Docker Container
Add another "Execute Shell" build step with the following command:docker run -d --name your-app-container -p 8080:8080 your-app-image:latest
Step 4: Save and Test the Pipeline
Save the project and click Build Now to test.
Jenkins will now:
Build the Docker image for your app.
Run the container using the image created.
Task 2: Automating docker-compose Commands in Jenkins
Step 1: Create a Freestyle Project for Docker Compose
In Jenkins, click "New Item".
Enter the project name (e.g., "Docker-Compose-Project") and select Freestyle Project.
Click OK to create the project.
Step 2: Configure Build Steps
Step 1: Run
docker-compose up
In the Build section, add an "Execute Shell" build step with:docker-compose up -dStep 2: Cleanup with
docker-compose down
Add a post-build action or another "Execute Shell" step for cleanup:docker-compose down
Step 3: Save and Test
Save the project and click Build Now to test.
Jenkins will now:
Start multiple containers using
docker-compose up.Stop and remove them using
docker-compose down.
What Youโll Achieve
Automated Docker image builds and container deployment via Jenkins.
Streamlined multi-container app deployment using Docker Compose.
Improved DevOps workflow with less manual intervention.


