Thanks to visit codestin.com
Credit goes to github.com

Skip to content

maruleq/jenkins-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jenkins-docker

🇬🇧 English | 🇵🇱 Polski

License: MIT Docker Compose Jenkins LTS

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.

Requirements

  • Docker with the Compose plugin (docker compose)
  • Docker binary accessible on the host (see Configuration)

Quick Start

# 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.sh

Jenkins will be available at: http://localhost:9090

To retrieve the initial admin password:

docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword

First-Time Setup

Jenkins requires a one-time setup wizard on first launch:

  1. Wait for Jenkins to start — it can take up to 60 seconds. Check readiness:

    docker ps  # STATUS should show "(healthy)"
  2. Open the browser at http://localhost:9090

  3. Unlock Jenkins — paste the initial admin password retrieved with:

    docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword
  4. Install plugins — choose "Install suggested plugins" (recommended for most users). This may take a few minutes.

  5. Create the first admin user — fill in the form and click "Save and Continue".

  6. Confirm the Jenkins URL — leave the default (http://localhost:9090/) and click "Save and Finish".

  7. Jenkins is ready. Click "Start using Jenkins".

ℹ️ All configuration (jobs, plugins, credentials) is persisted in ~/jenkins and survives container restarts and image updates.

Stopping Jenkins

./docker-stop.sh

Configuration

All 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

Docker binary path by OS

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 docker

Data Persistence

Jenkins data is stored in ~/jenkins on the host machine and survives container restarts.

File Structure

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)

Security Notice

⚠️ 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: true and running Jenkins as a non-root user

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages