🇬🇧 English | 🇵🇱 Polski
A minimal Docker Compose setup to run Jenkins LTS locally with access to the host Docker daemon, enabling Jenkins pipelines to build and run Docker containers.
- Docker with the Compose plugin (
docker compose) - Docker binary accessible on the host (see Configuration)
# 1. Copy the example environment file
cp .env.example .env
# 2. (Optional) Edit .env to match your system — especially DOCKER_BIN_PATH
nano .env
# 3. Start Jenkins
./docker-start.shJenkins will be available at: http://localhost:9090
To retrieve the initial admin password:
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPasswordJenkins requires a one-time setup wizard on first launch:
-
Wait for Jenkins to start — it can take up to 60 seconds. Check readiness:
docker ps # STATUS should show "(healthy)" -
Open the browser at http://localhost:9090
-
Unlock Jenkins — paste the initial admin password retrieved with:
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword -
Install plugins — choose "Install suggested plugins" (recommended for most users). This may take a few minutes.
-
Create the first admin user — fill in the form and click "Save and Continue".
-
Confirm the Jenkins URL — leave the default (
http://localhost:9090/) and click "Save and Finish". -
Jenkins is ready. Click "Start using Jenkins".
ℹ️ All configuration (jobs, plugins, credentials) is persisted in
~/jenkinsand survives container restarts and image updates.
./docker-stop.shAll configuration is done via the .env file (copy from .env.example):
| Variable | Default | Description |
|---|---|---|
JENKINS_PORT |
9090 |
Port exposed on the host |
DOCKER_BIN_PATH |
/usr/local/bin/docker |
Path to the Docker binary on the host machine |
| OS / install method | Typical path |
|---|---|
| Debian / Ubuntu (apt) | /usr/bin/docker |
| macOS / manual install | /usr/local/bin/docker |
Find the correct path on your system:
which dockerJenkins data is stored in ~/jenkins on the host machine and survives container restarts.
jenkins-docker/
├── docker-compose.yaml # Service definition
├── docker-start.sh # Starts the Jenkins container
├── docker-stop.sh # Stops the Jenkins container
├── .env.example # Example environment configuration
├── .gitignore
├── LICENSE
├── README.md # Documentation (EN)
└── README_PL.md # Documentation (PL)
⚠️ This setup prioritises convenience over security and is intended for local development use only.
The following security trade-offs are made deliberately:
| Setting | Risk | Reason |
|---|---|---|
privileged: true |
Container has full access to the host kernel | Required for Docker-in-Docker support |
user: root |
Processes run as root inside the container | Required to access the Docker socket |
Docker socket mount (/var/run/docker.sock) |
Jenkins can create, modify, or delete any container on the host — equivalent to root access | Required for pipelines that build/run Docker images |
Do not expose this Jenkins instance to the public internet without:
- Enabling authentication and authorization
- Setting up TLS (HTTPS)
- Replacing the Docker socket mount with a dedicated Docker-in-Docker sidecar (
docker:dind) - Removing
privileged: trueand running Jenkins as a non-root user