Skip to content

Commit 6f7d851

Browse files
authored
Use tabs for foreground and background example commands (#32)
1 parent 1b68762 commit 6f7d851

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

docs/tutorials/jenkins/jenkins-host-docker/Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ FROM jenkins/jenkins:lts-alpine
33
# Change user to root in order to have permissions to install packages.
44
USER root
55

6-
# Only Docker client is required inside the Jenkins container as the host systems Docker engine is used from inside the container.
6+
# Only Docker client is required inside the Jenkins container as the host
7+
# systems Docker engine is used from inside the container.
78
RUN apk add docker-cli
89

9-
# Note that the user is not switched back to jenkins here. This is to avoid problems with docker socket permissions.
10-
# Do not use root user in production. Instead, match group IDs of docker groups in host and container and add jenkins user to docker group.
10+
# Note that the user is not switched back to jenkins here. This is to avoid
11+
# problems with docker socket permissions. Do not use root user in production.
12+
# Instead, match group IDs of docker groups in host and container and add
13+
# jenkins user to the docker group.

docs/tutorials/jenkins/jenkins-host-docker/README.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,33 @@ When running Jenkins in a container, we will want to define ports and volumes. T
3030

3131
These files are available in the repository that provides this website. In order to run Jenkins container with Docker-in-Docker support, `cd` into `docs/tutorials/jenkins/jenkins-host-docker` directory and run `docker compose up`.
3232

33-
```sh
34-
cd docs/tutorials/jenkins/jenkins-host-docker
33+
=== "Background"
3534

36-
# If you want to see logs in the current terminal
37-
docker compose up --build
35+
To run the Jenkins container in the background, execute `docker compose up` command with `-d`/`--detach` flag:
3836

39-
# Or if you want to run the container in the background
40-
docker compose up --build --detach
41-
```
37+
```sh
38+
cd docs/tutorials/jenkins/jenkins-host-docker
39+
40+
docker compose up --build --detach
41+
```
42+
43+
This allows the Jenkins container to continue running even if you close the terminal session. Use `docker compose logs` command to see the logs.
44+
45+
=== "Foreground"
46+
47+
To run the Jenkins container in the foreground, execute `docker compose up` command without `-d`/`--detach` flag:
48+
49+
```sh
50+
cd docs/tutorials/jenkins/jenkins-host-docker
51+
52+
docker compose up --build
53+
```
54+
55+
You can now monitor the logs produced by the Jenkins container in your current shell. However, if you close the terminal session or send an interrupt signal (for example by pressing CTRL+C), the Jenkins container will be stopped.
56+
57+
---
4258

43-
The initial admin password can be easily printed with `docker compose exec`:
59+
The initial admin password can be printed with `docker compose exec` command:
4460

4561
```sh
4662
docker compose exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword

0 commit comments

Comments
 (0)