File tree Expand file tree Collapse file tree 1 file changed +28
-3
lines changed
03-cd/01-jenkins/00-instalando-jenkins Expand file tree Collapse file tree 1 file changed +28
-3
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
1
2
IMAGE=$1
2
- CERTS_VOLUME=$2
3
- DATA_VOLUME=$3
3
+ NETWORK=$2
4
+ CERTS_VOLUME=$3
5
+ DATA_VOLUME=$4
6
+
7
+ # Reference: https://forums.docker.com/t/how-to-filter-docker-ps-by-exact-name/2880/3
8
+
9
+ if [[ $( docker network ls --filter name=^/$NETWORK $) ]]; then
10
+ echo ' hello'
11
+ docker network create jenkins
12
+ echo ' network jenkins created'
13
+ fi
14
+
15
+ if [[ $( docker volume ls --filter name=^/$CERTS_VOLUME $) ]]; then
16
+ docker volume create $CERTS_VOLUME
17
+ echo network jenkins " $CERTS_VOLUME "
18
+ fi
19
+
20
+ if [[ $( docker volume ls --filter name=^/$CERTS_VOLUME $) ]]; then
21
+ docker volume create $DATA_VOLUME
22
+ echo network jenkins " $DATA_VOLUME "
23
+ fi
4
24
5
25
# StartDocker in Docker into jenkins network
6
26
docker container run --name jenkins-docker --rm --detach \
@@ -16,4 +36,9 @@ docker container run --name jenkins-blueocean --rm --detach \
16
36
--env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 \
17
37
--volume " $DATA_VOLUME " :/var/jenkins_home \
18
38
--volume " $CERTS_VOLUME " :/certs/client:ro \
19
- --publish 8080:8080 --publish 50000:50000 " $IMAGE "
39
+ --publish 8080:8080 --publish 50000:50000 " $IMAGE "
40
+
41
+ # Ensure that script have permissions to be executed: chmod +x start_jenkins.sh
42
+ # Build image from Dockerfile: docker build -t lemoncode/jenkins .
43
+ # From previous image we can run custom Jenkins version as follows:
44
+ # ./start_jenkins.sh lemoncode/jenkins jenkins jenkins-docker-certs jenkins-data
You can’t perform that action at this time.
0 commit comments