Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

将 Jenkins 从裸机运行迁移到 Docker 中 #251

Open
Bpazy opened this issue Oct 22, 2022 · 0 comments
Open

将 Jenkins 从裸机运行迁移到 Docker 中 #251

Bpazy opened this issue Oct 22, 2022 · 0 comments

Comments

@Bpazy
Copy link
Owner

Bpazy commented Oct 22, 2022

步骤说明:

  1. 我是用 Docker compose 来运行 Jenkins 的,所以先创建配置文件:
mkdir ~/jenkins && cd ~/jenkins
cat << EOF > docker-compose.yaml
version: '3'
services:
  jenkins:
    image: jenkins/jenkins:jdk11
    restart: unless-stopped
    ports:
      - "127.0.0.1:30000:8080"
    volumes:
      - "/home/ubuntu/jenkins/jenkins-data:/var/jenkins_home"
EOF
  1. 迁移裸机 Jenkins 的数据到容器中并修改文件权限:
# 以前我是用独立用户运行jenkins,现在 docker 不准备复用该用户了。
# 又因为 Jenkins 镜像指定了默认的 UID, GID 为 1000,对应我宿主机的用户则为 ubuntu。
sudo cp -r /home/jenkins/.jenkins ~/jenkins/jenkins-data
sudo chown -R ubuntu:ubuntu ~/jenkins/jenkins-data
  1. 迁移完毕,运行容器:sudo docker-compose up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant