How to Setup Jenkins in Docker Container? Last Updated : 06 Jan, 2025 Comments Improve Suggest changes Like Article Like Report Setting up of Jenkins in a docker container provides the facility of streamlining the CI/CD with scalability and consistency. It also helps for attaching the worker nodes as slaves and run the build jobs over their. In this article, we will guide you through the process of deploying jenkins in a Docker container over AWS Cloud EC2 instance. Table of Content What is Jenkins?How to Setup Jenkins in Docker Container? A Step-By-Step GuideDifference between Jenkins and Docker Why Jenkins use Docker?What is Jenkins?Jenkins is an open-source automation server widely used for continuous integration (CI) and continuous delivery (CD) processes in software development. It allows developers to automate the building, testing, and deployment of code changes, ensuring rapid and reliable software delivery. With its vast plugin ecosystem and flexibility, Jenkins has become a cornerstone tool for modern software development teams, enabling efficient collaboration and faster time-to-market for applications.Primary TerminologiesJenkins is an open-source automation server that is used to automate different parts of your software development related to building, testing, and deploying.Docker is a set of platforms as a service product that uses OS-level virtualization to deliver software in packages called containers.EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform.How to Setup Jenkins in Docker Container? A Step-By-Step GuideThe following are the steps that guides in setting up the jenkins in docker container using AWS EC2 instances:Step 1: First, log in to your AWS account and go to the EC2 service. There launch any free tier Amazon Linux machine. Here is the image attached to refer to.Make sure your Security inbound rules look like this. So that you don't have any further issues.Step 2: After launching, SSH to that EC2 instance. And Install Docker by running the following commands.sudo yum update -y # To update all packagessudo amazon-linux-extras install docker # To install docker latest versionsudo service docker start # To start docker servicesudo service docker status # To check status of docker service. If it's running or not.sudo systemctl enable docker # To ensure that docker service start after each reboot sudo usermod -a -G docker ec2-user # To add ec2-user to docker groupRefer to the below images for the output of the above commands.The following screenshot illustrates on installation of docker on AWS Amazon Linux:The following screenshot illustrates on the checking and starting the docker service:Now, to check if docker is installed or not. Run below command and match with an image attached further.docker -v # It will give you docker versionStep 3: Now we will pull the Jenkins image using docker from the docker hub. Run the following command to pull the docker images such jenkins/jenkins.docker pull jenkins/jenkins # To pull the image of jenkinsdocker images # To see if image is downloaded or notPlease refer to the image attached for a better understanding.Step 4: Since in docker images we can see our Jenkins image. Now we can make our Jenkins container. But before that make a directory. Run below command mkdir jenkins #To make directory name jenkins After making this directory run the below command Please refer to the image attached ahead for a better understanding.docker run -d --name jenkins -p 8080:8080 -v $PWD/jenkins/ jenkins/jenkins # To run a container name jenkins using jenkins image docker ps # To see if container is running or not Now, copy the Public IPv4 address of the EC2 instance. Refer to the below image for any confusion.After copying it. Paste it into a new tab and write it with port 8080. Refer the below image for better understanding and resolving confusion.After running this, you'll see a screen like this.Step 5: To get this password. Run the below command in the EC2 instance and copy the password. Refer to the image if there is any confusion.docker logs jenkins #To see logs of the container name jenkins After entering this password, Install all the plugins (it may take a while). Step 6: Once all the plugins are installed you'll be asked to make a user with a password and After making that user. You'll be logged into Jenkins.The following screenshot illustrates on creation of new admin user:Access to the jenkins web dashobard as shown in the below screenshot.Congratulations! If you have come this far that's mean you have successfully set up the Jenkins in Docker container. Now you can easily automate your software using Jenkins.Difference between Jenkins and Docker The following are the difference between Jenkins and docker:AspectJenkinsDockerPurposeJenkins is a tool that used for Continuous Integration and Continuous Delivery (CI/CD) for automating software development processesIt is a containerization platform that is used for building, deploying, and managing applications within containersFunctionalityIt manages and automates tasks such as building, testing, and deploying code across different stages of the development pipelineit creates lightweight, portable containers that encapsulate applications with all their dependencies providing consistent and reproducible environmentsArchitectureIt follows master-slave architecture where jenkins master coordinates tasks and distributes work to multiple slave nodesIt comes with Client-server architecture, where Docker Engine acts as the server managing containers, and Docker CLI interacts with the server to execute commandsUse CasesIt is ideal for automating software development workflows. It integrates with version control systems, and orchestrating complex build and deployment pipelinesIt is suitable for containerizing applications, microservices, and distributed systems, providing flexibility, scalability, and portability across different environmentsWhy Jenkins use Docker?The following are the reasons for jenkins using docker:Scalability: Docker facilitates the jenkins with dynamically provision features for build agents as Docker containers allowsing for efficient scaling of resources based on workload demands.Isolation: Docker provides light weighted isolated containers for running build jobs, ensuring each build runs in its isolated enviornments.Consistency: By using docker continers, jenkins ensures the consistency between development, testing and production environments. Resource Efficiency: Docker containers consumes fewer resources compared to the traditional vritual machines making them a more efficient choice for running build jobs. Comment More infoAdvertise with us Next Article How to Setup Jenkins in Docker Container? P prakashpratham89 Follow Improve Article Tags : DevOps Jenkins Similar Reads Docker Tutorial Docker is a tool that simplifies the process of developing, packaging, and deploying applications. By using containers, Docker allows you to create lightweight, self-contained environments that run consistently on any system, minimising the time between writing code and deploying it into production. 7 min read IntroductionWhat is Docker?Have you ever wondered about the reason for creating Docker Containers in the market? Before Docker, there was a big issue faced by most developers whenever they created any code that code was working on that developer computer, but when they try to run that particular code on the server, that code 12 min read Features of DockerPre-requisite: Docker Docker is one of the most popular open-source sets of platforms for developing and automating the deployment of applications. It deploys applications into containers and enables us to separate our applications from infrastructure. It is designed to provide a lightweight and fas 4 min read Architecture of DockerPre-requisite: DockerDocker makes use of a client-server architecture. The Docker client talks with the docker daemon which helps in building, running, and distributing the docker containers. The Docker client runs with the daemon on the same system or we can connect the Docker client with the Docke 4 min read What is Docker Hub?Docker Hub is a repository service and it is a cloud-based service where people push their Docker Container Images and also pull the Docker Container Images from the Docker Hub anytime or anywhere via the internet. It provides features such as you can push your images as private or public. Mainly De 12 min read What is Docker Cloud?Docker is a software platform that provides some special kind of facilities, like a service provider that allows you to build, test, and deploy your application in centralized processing and quickly. So, the Docker Cloud is basically working as a service provider by Docker in which we can perform su 10 min read Docker InstallationDocker - Installation on WindowsIn this article, we are going to see how to install Docker on Windows. On windows if you are not using operating system Windows 10 Pro then you will have to install our docker toolbox and here docker will be running inside a virtual machine and then we will interact with docker with a docker client 2 min read How to Install Docker using Chocolatey on Windows?Installing Docker in Windows with just the CLI is quite easier than you would expect. It just requires a few commands. This article assumes you have chocolatey installed on your respective windows machine. If not, you can install chocolatey from here. Chocolatey is a package manager for the Windows 4 min read How to Install and Configure Docker in Ubuntu?Docker is a platform and service-based product that uses OS-level virtualization to deliver software in packages known as containers. Containers are separated from one another and bundle their software, libraries, and configuration files. Docker is written in the Go language. Docker can be installed 6 min read How to Install Docker on MacOS?Pre-requisites: Docker-Desktop Docker Desktop is a native desktop application for Windows and Mac's users created by Docker. It is the most convenient way to launch, build, debug, and test containerized apps. Docker Desktop includes significant and helpful features such as quick edit-test cycles, fi 2 min read How to install and configure Docker on Arch-based Linux Distributions(Manjaro) ?In this article, we are going to see how to install and configure Docker on Arch-based Linux Distributions. Docker is an open-source containerization platform used for building, running, and managing applications in an isolated environment. A container is isolated from another and bundles its softwa 2 min read How to Install Docker-CE in Redhat 8?Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all the parts it needs, such as libraries and other dependencies, and deploy it as one package. Installing Docker-CE in Redhat 8: St 2 min read Docker CommandsDocker CommandsDocker is an open-source project that automates the deployment of applications as movable, independent containers that can run locally or in the cloud. You can divide your applications from your infrastructure with the help of Docker, allowing for quick software delivery and it also allows you to ma 7 min read How to Install Docker using Chocolatey on Windows?Installing Docker in Windows with just the CLI is quite easier than you would expect. It just requires a few commands. This article assumes you have chocolatey installed on your respective windows machine. If not, you can install chocolatey from here. Chocolatey is a package manager for the Windows 4 min read How to Install and Configure Docker in Ubuntu?Docker is a platform and service-based product that uses OS-level virtualization to deliver software in packages known as containers. Containers are separated from one another and bundle their software, libraries, and configuration files. Docker is written in the Go language. Docker can be installed 6 min read How to Install Docker on MacOS?Pre-requisites: Docker-Desktop Docker Desktop is a native desktop application for Windows and Mac's users created by Docker. It is the most convenient way to launch, build, debug, and test containerized apps. Docker Desktop includes significant and helpful features such as quick edit-test cycles, fi 2 min read How to install and configure Docker on Arch-based Linux Distributions(Manjaro) ?In this article, we are going to see how to install and configure Docker on Arch-based Linux Distributions. Docker is an open-source containerization platform used for building, running, and managing applications in an isolated environment. A container is isolated from another and bundles its softwa 2 min read How to Install Docker-CE in Redhat 8?Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all the parts it needs, such as libraries and other dependencies, and deploy it as one package. Installing Docker-CE in Redhat 8: St 2 min read Docker CommandsDocker CommandsDocker is an open-source project that automates the deployment of applications as movable, independent containers that can run locally or in the cloud. You can divide your applications from your infrastructure with the help of Docker, allowing for quick software delivery and it also allows you to ma 7 min read Running Commands Inside Docker ContainerIf you are working on an application inside the Docker Container, you might need commands to install packages or access file system inside the Docker Container. Executing commands inside Docker Containers should be easy enough for you since you have to do it multiple times across your development ph 6 min read Docker - USER InstructionBy default, a Docker Container runs as a Root user. This poses a great security threat if you deploy your applications on a large scale inside Docker Containers. You can change or switch to a different user inside a Docker Container using the USER Instruction. For this, you first need to create a us 2 min read Docker ImagesWhat is Docker Image?Docker Image is an executable package of software that includes everything needed to run an application. This image informs how a container should instantiate, determining which software components will run and how. Docker Container is a virtual environment that bundles application code with all the 10 min read Working with Docker ImagesIf you are a Docker developer, you might have noticed that working with multiple Docker Images at the same time might be quite overwhelming sometimes. Managing numerous Docker Images all through a single command line is a very hefty task and consumes a lot of time. In this article, we are going to d 2 min read Docker - Publishing Images to Docker HubDocker is a container platform that facilitates creating and managing containers. In this article, we will see how docker stores the docker images in some popular registries like Dockerhub and how to publish the Docker images to Docker Hub. By publishing the images to the docker hub and making it pu 8 min read Docker CommitDocker is an open-source container management service and one of the most popular tools of DevOps which is being popular among the deployment team. Docker is mostly used in Agile-based projects which require continuous delivery of the software. The founder, Chief Technical Officer, and Chief Archite 10 min read Docker - Using Image TagsImage tags are used to describe an image using simple labels and aliases. Tags can be the version of the project, features of the Image, or simply your name, pretty much anything that can describe the Image. It helps you manage the project's version and lets you keep track of the overall development 7 min read Next.js Docker ImagesUsing Next.js Docker images allows your app to deploy to multiple environments, and is more portable, isolated and scalable in dev and prod. Dockerâs containerization makes app management super easy, you can move from one stage to another with performance.Before we get started, letâs cover the basic 14 min read How to Use Local Docker Images With Minikube?Minikube is a software that helps in the quick setup of a single-node Kubernetes cluster. It supports a Virtual Machine (VM) that runs over a docker container and creates a Kubernetes environment. Now minikube itself acts as an isolated container environment apart from the local docker environment, 7 min read Docker ComposeDocker ComposeAn open-source platform called Docker makes designing, shipping, and deploying applications simple. It runs an application in an isolated environment by compiling its dependencies into a so-called container. for additional information on Docker. In a normal case, several services, such as a database 15+ min read Docker Compose Tool To Run aMulti Container ApplicationsThe article talks about how to run multi-container applications using a single command. Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you can configure a file (YAML file) to configure your docker containers. Then Once you configured the Yaml fil 8 min read Docker Engine, StorageData Storage in DockerDocker images are built-in form of layers and docker containers store all the data being used, on the container writable layer which is only persisted till the lifespan of the container i.e. it is no longer accessible once the container is removed. This also makes it difficult to get the data out of 4 min read Data Storage in DockerDocker images are built-in form of layers and docker containers store all the data being used, on the container writable layer which is only persisted till the lifespan of the container i.e. it is no longer accessible once the container is removed. This also makes it difficult to get the data out of 4 min read Backing up a Docker ContainerIf you are a Docker Developer, you would surely know how important it is to backup your Docker Container file system. If you are working on an important Docker Application, it becomes very necessary to backup all the files and folders related to it so that in case anything goes wrong, you can get ba 2 min read Using CLI to Manage Docker VolumesIf you want to share files and directories among multiple Docker Containers, you can easily mount Docker Volumes to different Containers. However, managing such a large number of Docker Volumes becomes very difficult at times. In this article, we are going to discuss how to manage Docker Volumes by 7 min read Docker NetworkingDocker NetworkingPre-requisite: Docker Docker Networking allows you to create a Network of Docker Containers managed by a master node called the manager. Containers inside the Docker Network can talk to each other by sharing packets of information. In this article, we will discuss some basic commands that would help 5 min read Docker - Managing PortsPre-requisites: Docker Docker is a set of platform-as-a-service products that use OS-level virtualization to deliver software in packages called containers. These containers may need to talk to each other or to services outside docker, for this we not only need to run the image but also expose the c 4 min read Creating a Network in Docker and Connecting a Container to That NetworkNetworks are created so that the devices which are inside that network can connect to each other and transfer of files can take place. In docker also we can create a network and can create a container and connect to the respective network and two containers that are connected to the same network can 2 min read Connecting Two Docker Containers Over the Same NetworkWhenever we expose a container's port in docker, it creates a network path from the outside of that machine, through the networking layer, and enters that container. In this way, other containers can connect to it by going out to the host, turning around, and coming back in along that path.Docker of 3 min read How to use Docker Default Bridge Networking?Docker allows you to create dedicated channels between multiple Docker Containers to create a network of Containers that can share files and other resources. This is called Docker Networking. You can create Docker Networks with various kinds of Network Drivers which include Bridge drivers, McVLAN dr 7 min read Create your own secure Home Network using Pi-hole and DockerPi-hole is a Linux based web application, which is used as a shield from the unwanted advertisement in your network and also block the internet tracking system. This is very simple to use and best for home and small office networks. This is totally free and open-source. It also allows you to manage 3 min read Docker RegistryWhat is Docker Registry?Docker Registry is a centralized storage and distributed system for collecting and managing the docker images. It provides both public and private repositories as per the choice whether to make the image accessible publicly or not. It is an essential component in the containerization workflow for st 10 min read Docker - Using Public Repositories To Host Docker ImagesDocker is a software platform for creating isolated virtualized environments for building, deploying, and testing applications with ease. In this tutorial, we will learn how to host public repositories on docker hub which is a hosted repository service provided by Docker for finding and sharing cont 10 min read Docker - Private RegistriesPre-requisites: Docker, Docker HUB Docker registry is your own private repository where you can store your own Docker images and share them with others. Docker Registry is basically organized into Docker Repositories. Within the docker Repository, you can maintain specific versions of a Docker Image 3 min read Creating a Private Repository and Push an Image to That Private RepositoryIn this article, we show how to create a docker hub account and pull the image from the docker hub repository and push our image to the docker hub repository. As the docker hub is a public repository that can be accessed by anyone so one can create their own private repository to which they can push 2 min read Docker - Using Public Repositories To Host Docker ImagesDocker is a software platform for creating isolated virtualized environments for building, deploying, and testing applications with ease. In this tutorial, we will learn how to host public repositories on docker hub which is a hosted repository service provided by Docker for finding and sharing cont 10 min read Like