Code Monkey home page Code Monkey logo

docker-jenkins's Introduction

docker-jenkins

Jenkins Docker镜像

一、构建镜像

git clone https://github.com/fifilyu/docker-jenkins.git
cd docker-jenkins
docker buildx build -t fifilyu/jenkins:latest .

二、开放端口

  • sshd->22
  • Jenkins->8080

三、启动容器(数据分离)

3.1 预先准备开放权限的数据和日志目录

sudo mkdir -p /data/jenkins/logs
sudo chmod -R 777 /data/jenkins

3.2 启动带目录映射的容器

docker run -d \
    --env LANG=en_US.UTF-8 \
    --env TZ=Asia/Shanghai \
    -e PUBLIC_STR="$(<~/.ssh/[email protected])" \
    -p 1022:22 \
    -p 1808:8080 \
    -v /data/jenkins/:/var/lib/jenkins/.jenkins/ \
    -v /data/jenkins/logs:/var/log/jenkins/ \
    -h jenkins \
    --name jenkins \
    fifilyu/jenkins:latest

3.3 重置目录权限

# 目录降级读写权限
sudo chmod 755 /data/jenkins /data/jenkins/logs

# 使用容器内的jenkins用户和组的id重置目录用户组
uid=$(docker exec -it jenkins bash -c 'id -u jenkins' | tr -d '\r')
gid=$(docker exec -it jenkins bash -c 'id -g jenkins' | tr -d '\r')

sudo chown -R ${uid}:${gid} /data/jenkins

# 确认重置效果
ls -dln /data/jenkins && ls -al /data/jenkins

3.4 重启容器

必须重启容器,否则容器无法读写映射目录

docker restart jenkins

四、使用Jenkins

4.1 查看初始密码

sudo cat /data/jenkins/secrets/initialAdminPassword

4.2 访问Jenkins

http://localhost:1808/

docker-jenkins's People

Contributors

fifilyu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.