在Docker中运行Jenkins

  • 下载镜像

    1
    docker pull jenkins/jenkins:lts
  • 创建/Users/blant/work/docker/jenkins_home/data/log.properties

    1
    vi /Users/blant/work/docker/jenkins_home/data/log.properties

    log.properties内容

    1
    2
    3
    handlers=java.util.logging.ConsoleHandler
    jenkins.level=FINEST
    java.util.logging.ConsoleHandler.level=FINEST
  • 后台启动jenkins

    1
    docker run --name myjenkins -p 8080:8080 -p 50000:50000 --env JAVA_OPTS="-Djava.util.logging.config.file=/var/jenkins_home/data/log.properties" -v /Users/blant/work/docker/jenkins_home:/var/jenkins_home -d jenkins/jenkins:lts
  • 进入容器

    1
    docker exec -it myjenkins /bin/bash
  • 浏览器访问
    localhost:8080

上一篇