-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-jenkins.sh
48 lines (39 loc) · 1.28 KB
/
docker-jenkins.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
mkdir jenkins2-docker
cd jenkins2-docker
echo "FROM jenkinsci/jenkins:latest
USER root
RUN mkdir /var/log/jenkins
RUN mkdir /var/cache/jenkins
RUN chown -R jenkins:jenkins /var/log/jenkins
RUN chown -R jenkins:jenkins /var/cache/jenkins
USER jenkins
ENV JAVA_OPTS=\"-Xmx8192m\"
" >> Dockerfile
echo "FROM debian:jessie
# Create the jenkins user
RUN useradd -d \"/var/jenkins_home\" -u 1000 -m -s /bin/bash jenkins
# Create the folders and volume mount points
RUN mkdir -p /var/log/jenkins
RUN chown -R jenkins:jenkins /var/log/jenkins
VOLUME [\"/var/log/jenkins\", \"/var/jenkins_home\"]
USER jenkins
CMD [\"echo\", \"Data container for Jenkins\"]
" >> Dockerfile-data
docker build -t jenkins-data -f Dockerfile-data .
docker build -t jenkins2 .
docker run --name=jenkins-data jenkins-data
docker run -p 8080:8080 -p 50000:50000 --name=jenkins-master --volumes-from=jenkins-data -d jenkins2
echo ""
echo ""
echo "################################"
echo "# browse: http://localhost:8080 "
echo "# enter password: "
sleep 2
echo "################################"
echo "################################"
echo ""
docker exec jenkins-master cat /var/jenkins_home/secrets/initialAdminPassword
echo ""
echo "################################"
echo "################################"