Menu

Jenkins Setup in Docker using Docker Compose
📰

Jenkins Setup in Docker using Docker Compose

DEV Community: cicd·Raghavvram Johnson·3 days ago
#HtSyYrWy
#devtocicd#devto#dev#jenkins#docker
Reading 0:00
15s threshold

To run Jenkins in Docker, use the following production-ready docker-compose.yml file. This configuration includes data persistence and mounts the Docker socket so Jenkins can build and run other Docker containers inside your pipelines.

1. The docker-compose.yml File

services : jenkins : image : jenkins/jenkins:lts container_name : jenkins restart : unless-stopped privileged : true user : root ports : - " 8181:8080" # Jenkins Web UI - " 50000:50000" # Jenkins inbound agents port volumes : - ./jenkins_data:/var/jenkins_home - /var/run/docker.sock:/var/run/docker.sock

Enter fullscreen mode

Exit fullscreen mode

2. How to Start Jenkins

Create a directory for your project and navigate into it:

mkdir jenkins-docker && cd jenkins-docker

Save the configuration above into a file named docker-compose.yml .

Start the container in the background:

docker compose up -d

3. Retrieve the Initial Admin Password

Once the container starts, Jenkins will generate a one-time setup password.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.