Skip to content

Commit bcb4f2f

Browse files
authored
Update dind-jenkins example (#2)
1 parent 0a8793d commit bcb4f2f

2 files changed

Lines changed: 26 additions & 14 deletions

File tree

examples/jenkins/dind-jenkins/README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,28 @@
22

33
Note that by default each of the example docker compose configurations will create their own volumes for the data. This might not be what you want. In order to use the same volumes for every docker compose configuration, run docker compose with `-p` (or `--project-name`) option. This can also be done by setting `COMPOSE_PROJECT_NAME` environment variable:
44

5-
```bash
5+
```sh
66
export COMPOSE_PROJECT_NAME=jenkins
77
```
88

99
## Jenkins image with Docker-in-Docker support
1010

11-
In order to run Jenkins container with Docker-in-Docker support, `cd` into [dind-jenkins](./dind-jenkins/) directory and run `docker compose up`. See Dockerfile and docker compose.yml for the configuration details.
11+
To be able run Docker commands from inside the Jenkins container, we will need to install the Docker client. This can be done with a suitable Dockerfile:
1212

13-
```bash
14-
cd dind-jenkins/
13+
```Dockerfile title="Dockerfile"
14+
--8<-- "examples/jenkins/dind-jenkins/Dockerfile"
15+
```
16+
17+
When running this container, we will want to define ports and volumes. To do this, we will use a `docker-compose.yml` configuration:
18+
19+
```yaml title="docker-compose.yml"
20+
--8<-- "examples/jenkins/dind-jenkins/docker-compose.yml"
21+
```
22+
23+
These files are available in the repository that provides this website. In order to run Jenkins container with Docker-in-Docker support, `cd` into `examples/jenkins/dind-jenkins` directory and run `docker compose up`.
24+
25+
```sh
26+
cd examples/jenkins/dind-jenkins
1527

1628
# If you want to see logs in the current terminal
1729
docker compose up --build
@@ -22,8 +34,8 @@ docker compose up --build --detach
2234

2335
The initial admin password can be easily printed with `docker compose exec`:
2436

25-
```bash
37+
```sh
2638
docker compose exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword
2739
```
2840

29-
In order to get started the suggested plugins are often good a starting point. If you are planning to create pipeline projects with stages running in on-demand Docker containers, you will also need [Docker Pipeline](https://plugins.jenkins.io/docker-workflow/) plugin. This can be installed through the [Manage Jenkins > Manage plugins](http://localhost:8080/pluginManager/available) menu.
41+
In order to get started with Jenkins, the suggested plugins are often good a starting point. If you are planning to create pipeline projects with stages running in on-demand Docker containers, you will also need [Docker Pipeline](https://plugins.jenkins.io/docker-workflow/) plugin. This can be installed through the [Manage Jenkins > Manage plugins](http://localhost:8080/pluginManager/available) menu.

examples/jenkins/dind-jenkins/docker-compose.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ services:
22
jenkins:
33
build: .
44
ports:
5-
# Web user interface
6-
- 8080:8080
7-
# Java agents
8-
- 50000:50000
5+
# Web user interface
6+
- 8080:8080
7+
# Java agents
8+
- 50000:50000
99
volumes:
10-
# Persistent volume for the Jenkins data
11-
- "jenkins.data:/var/jenkins_home"
12-
# Host systems docker socket
13-
- "/var/run/docker.sock:/var/run/docker.sock"
10+
# Persistent volume for the Jenkins data
11+
- "jenkins.data:/var/jenkins_home"
12+
# Host systems docker socket
13+
- "/var/run/docker.sock:/var/run/docker.sock"
1414

1515
volumes:
1616
jenkins.data:

0 commit comments

Comments
 (0)