事倍功半是蠢蛋73 三谈jenkins 本地构建仓库让他本地编译然后推送

# 在Linux上,使用反斜杠 \ 作为换行符,或者直接写一行
docker run -d \
  -p 5000:5000 \
  --restart=always \
  --name registry \
  registry:2

docker run -d -p 5000:5000 --restart=always --name registry registry:2

# 查看运行中的容器
docker ps | grep registry

# 如果没看到,查看所有容器(包括停止的)
docker ps -a | grep registry

# 查看Registry日志(如果有问题)
docker logs registry

然后让ai生成一个helloworld的 推送范例


# 1. 构建镜像
docker build -t localhost:5000/hello-test:v1 -f Dockerfile.hello-test .

# 2. 推送镜像
docker push localhost:5000/hello-test:v1

# 3. 验证推送成功
curl http://localhost:5000/v2/_catalog
curl http://localhost:5000/v2/hello-test/tags/list

# 4. 删除本地镜像
docker rmi localhost:5000/hello-test:v1

# 5. 拉取镜像
docker pull localhost:5000/hello-test:v1

# 6. 运行测试
docker run --rm localhost:5000/hello-test:v1
# 如果配置不对,重新编辑
sudo nano /etc/docker/daemon.json

# 确保内容是:
{
  "insecure-registries": ["localhost:5000", "127.0.0.1:5000"]
}

# 重启Docker
sudo systemctl restart docker

# 重新启动Registry
docker start registry

image

设置中文改了

1)首先,开发人员每天进行代码提交,提交到Git仓库
2)然后,Jenkins作为持续集成工具,利用webhook插件检测GitLab仓库代码变动,使用Git工具到Git仓库拉取代码到集成服务器

image

在gitlab里集成

mulitbranch

build with parameter 决定编译哪些

解决问题

sudo usermod -aG docker jenkins

临时:
sudo chmod 666 /var/run/docker.sock

image

https://chuna2.787528.xyz/a565810497/p/18400243

原来我的想法是webhook触发 然后几个机器就不需要联网拉取了 直接内网拉取jenkins部署服务器同ip下自创的docker registery就得了

就是我们先在本地启动一个镜像仓库 然后部署过程就是拉取镜像而非代码然后运行

但是做到一半webhook触发搞定之后发现这么做要考虑跟配的东西太繁琐太多了也可以做但是时间不够用了(没划定jenkins工期) 所以最后还是采用了 远程触发git pull的形式。

posted @ 2026-01-04 16:54  空心橙子  阅读(0)  评论(0)    收藏  举报