This repository provides various ways to use Docker with Jenkins agents.
Jenkins is a popular open-source automation server that allows you to automate various tasks, including building, testing, and deploying software. Jenkins agents are responsible for executing the jobs or tasks defined in Jenkins.
Docker is a containerization platform that allows you to package applications and their dependencies into lightweight, portable containers. Using Docker with Jenkins agents can provide several benefits, such as isolation, reproducibility, and scalability.
To get started with using Docker with Jenkins agents, follow these steps:
- Clone this repository:
git clone https://github.com/mohammadmmoniri/jenkins-agent-with-docker.git
- Install Docker on your machine if you haven't already. Refer to the official Docker documentation for installation instructions specific to your operating system.
- Choose one of the methods provided in this repository for running Jenkins agents with Docker.
- Follow the instructions in the respective method's directory to set up and configure the Jenkins agent using Docker.
- Run the Jenkins agent container and connect it to your Jenkins server.
- Start running your Jenkins jobs using the Docker-based agent.
This repository provides the following methods for using Docker with Jenkins agents:
-
Method 1: Docker-in-Docker (DinD)
- This method involves running a Jenkins agent container with Docker installed inside it. It allows you to run Docker commands and build Docker images within the agent container.
- See the
dind
directory for detailed instructions.
-
Method 2: Docker Socket Sharing
- This method involves sharing the Docker socket from the host machine with the Jenkins agent container. It allows the agent to communicate directly with the Docker daemon on the host.
- See the
docker-socket-sharing
directory for detailed instructions.
Choose the method that best suits your requirements and follow the instructions provided in the respective directory.
If you would like to contribute to this repository, please follow these guidelines:
- Fork the repository.
- Create a new branch for your feature or bug fix:
git checkout -b my-feature
. - Make your changes and commit them with descriptive commit messages.
- Push your changes to your forked repository.
- Submit a pull request detailing your changes.
This repository is licensed under the MIT License. Feel free to use and modify the code as per your needs.
We would like to thank the Jenkins and Docker communities for their excellent documentation and resources that helped in creating this repository.
Happy Jenkins automation with Docker!