我正在编写此Dockerfile来生成docker映像。
-> Dockerfile
FROM centos:7
MAINTAINER Glen
ENV TZ "Asia/Shanghai"
ADD jdk1.8.0_151 jenkins.war /usr/local/
RUN ln -sv /usr/local/jdk1.8.0_151/bin/java* /bin/
EXPOSE 80
CMD cd /usr/local/jdk1.8.0_151 && nohup java -jar jenkins.war >> jenkins.log &
我认为Dockerfile中的CMD行应该已经启动了Jenkins,但是当我构建映像并执行它时,什么也没有发生。我必须键入以下命令来启动Jenkins:
docker exec -ti 65aeca0b6e3ed9f572e87379e181f6941178ec30d8a38f5c4b5ccd0fee97e92e bash
[root@65aeca0b6e3e /]# cd usr/local
[root@65aeca0b6e3e local]# ll
[root@65aeca0b6e3e local]# ps -ef| grep java
[root@65aeca0b6e3e local]# java -jar jenkins.war >> jenkins.log
是否仍然需要更改我的Dockerfile,以便Jenkins和日志可以自行启动?
答案 0 :(得分:0)
尝试使用此Dockerfile:
FROM centos:7
MAINTAINER Glen
ENV TZ "Asia/Shanghai"
ADD jdk1.8.0_151 jenkins.war /usr/local/
RUN ln -sv /usr/local/jdk1.8.0_151/bin/java* /bin/
EXPOSE 80
WORKDIR /usr/local/jdk1.8.0_151
CMD ["java", "-jar", "jenkins.war", ">>", "jenkins.log"]
顺带一提,为什么不使用官方的Docker jenkins