CICD - docker私有仓库

1、创建私有仓库

docker pull  registry
docker run -d -v /opt/registory:/var/lib/registory  -p 5000:5000 --restart=always --name registry registry

2、查看私有仓库

curl http://47.99.211.128:5000/v2/_catalog
# 域名解析后
curl http://hub.chenhailong.online/v2/_catalog
{"repositories":[]}

CICD - docker私有仓库_第1张图片
3、 将制作的镜像推到私有仓库

# 参考docker hub官网
docker push chenhailong666/test:tagname
  • 没成功
[root@iZbp1hun1qsl59e2nzqyvcZ ~]# docker push 47.99.211.128:5000/test:1.0
The push refers to repository [47.99.211.128:5000/test]
Get https://47.99.211.128:5000/v2/: http: server gave HTTP response to HTTPS client
[root@iZbp1hun1qsl59e2nzqyvcZ ~]# curl http://47.99.211.128:5000/v2/_catalog
{"repositories":[]} 
[root@iZbp1hun1qsl59e2nzqyvcZ ~]# 
  • 不加https, 授信
vi /etc/docker/daemon.json

# daemon.json
# 加入解析后的域名
{"insecure-registries":["47.99.211.128:5000","hub.chenhailong.online"]}
  • 记录已经在运行的容器
    在这里插入图片描述
  • 完成授信,重启docker
service docker restart
docker image ls
# ----------查看
REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE
47.99.211.128:5000/test              1.0                 b733ed3d34c8        3 days ago          675MB
chenhailong666/test                  1.0                 b733ed3d34c8        3 days ago          675MB
jenkinsci/blueocean                  latest              7959e11c0266        6 days ago          555MB
nginx                                latest              2bcb04bdb83f        4 weeks ago         109MB
registry                             latest              f32a97de94e1        7 weeks ago         25.8MB
mysql                                5.6                 96e41ac53eac        2 months ago        256MB
jenkins                              latest              cd14cecfdb3a        9 months ago        696MB
maven                                3-alpine            5435658a63ac        21 months ago       116MB
hub.c.163.com/wuxukun/maven-aliyun   3-jdk-8             676639454cb4        2 years ago         653MB

docker push 47.99.211.128:5000/test:1.0

CICD - docker私有仓库_第2张图片

  • 删除私有仓库镜像
    CICD - docker私有仓库_第3张图片
  • 将已有运行的docker容器改成 --restart=always
    • 将容器删除
    • 改成–restart=always
    • docker run --name=nginx -p 80:80 -v /app/nginx/www:/usr/share/nginx/html -v /app/nginx/conf.d:/etc/nginx/conf.d -d --restart=always nginx
      CICD - docker私有仓库_第4张图片

参考:
博文
视频链接

你可能感兴趣的:(jenkins,cicd)