A local Jenkins environment for running CI/CD pipelines with Docker support.
This project runs Jenkins inside a Docker container using Docker Compose.
Jenkins can access the host Docker daemon through the Docker socket:
/var/run/docker.sock
This allows Jenkins pipelines to run Docker commands such as docker build, docker run, and docker push.
This setup uses the host Docker socket. It is not a full Docker-in-Docker setup.
jenkins-docker/
├── .gitignore
├── Dockerfile
├── README.md
├── docker-compose.yml
└── plugins.txt
- Jenkins LTS running in Docker
- Docker CLI available inside the Jenkins container
- Python 3, pip, and venv for Python-based pipelines
- curl for health checks
- Jenkins plugins installed from
plugins.txt - Persistent Jenkins data using a named Docker volume
- Access to the host Docker daemon through
/var/run/docker.sock
- Docker
- Docker Compose
On macOS, Docker Desktop must be running before starting Jenkins.
Build and start Jenkins:
docker compose up -d --buildOpen Jenkins in the browser:
http://localhost:8080
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPasswordUse this password to complete the initial Jenkins setup.
The Jenkins container mounts the host Docker socket:
- /var/run/docker.sock:/var/run/docker.sockThe container is also added to group 0:
group_add:
- "0"This works for this local Docker Desktop setup. On some Linux systems, the Docker socket group may be different and group_add may need to be adjusted.
To verify Docker access from inside the Jenkins container:
docker exec -it jenkins docker psIf the command lists running containers, Jenkins can access Docker.
Start Jenkins:
docker compose up -dRebuild and start Jenkins:
docker compose up -d --buildStop Jenkins:
docker compose stopRestart Jenkins:
docker compose restartView logs:
docker compose logs -fRemove the Jenkins container:
docker compose downRemove the Jenkins container and delete Jenkins data:
docker compose down -vThis setup mounts the host Docker socket so Jenkins can run Docker commands from inside the container.
It is designed for local development, CI/CD practice, and portfolio projects.
This Jenkins environment can be used with the companion FastAPI project:
The companion project contains a FastAPI application and a Jenkins pipeline that runs tests, builds a Docker image, pushes it to Docker Hub, deploys the container, and verifies the /health endpoint.