docker自行构建jenkins
1.dockerfile。yum clean 和yum makecache 是yum jenkins.时会报错.initscripts是为了在容器中执行jenkins start.
&& tail -f /dev/null 是为了保证容器启动后不立即退出。
FROM docker.io/centos:latest MAINTAINER <FeigerLan>
RUN yum install -y java-1.8.0 && yum install -y wget && yum install -y initscripts RUN echo "nameserver 8.8.8.8" >> /etc/resolv.conf RUN wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo RUN rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key RUN yum clean all RUN yum makecache && yum install jenkins -y RUN sed -i 's/JENKINS_PORT=\"8080\"/JENKINS_PORT=\"49000\"/' /etc/sysconfig/jenkins RUN ./etc/init.d/jenkins restart CMD /etc/init.d/jenkins start && tail -f /dev/null
注意。区别 RUN , CMD作用
构建命令:
docker build -t docker.io/centos:jenkins04 ./
容器运行命令:
docker run -dit --name jenkins04 -p 8088:49000 centos:jenkins04
效果:
[root@localhost jenkins_dockerfile]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fcc8a1da92ff centos:jenkins04 "/bin/sh -c '/etc/..." 21 minutes ago Up 21 minutes 0.0.0.0:8091->49000/tcp jenkins04