ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

K8S学习笔记之docker registry使用http非https

2022-08-29 18:01:44  阅读:210  来源: 互联网

标签:systemd 5000 http 16.3 registry https 172.16 docker


0x00 概述

本地调试环境,docker registry不需要使用https,规避复杂操作。

 

0x01 默认https传输问题

docker registry默认使用https,在私有镜像源操作会提示以下错误:

vm01@root:~$ docker push 172.16.16.3:5000/alpine:v1.0
The push refers to repository [172.16.16.3:5000/alpine]
Get https://172.16.16.3:5000/v2/: http: server gave HTTP response to HTTPS client

 

0x02 修改docker registory配置 

在docker的daemon.json文件内,新增私有镜像源信息(在K8S被所有节点进行此操作)

vm01@shenzhen:~$ cat /etc/docker/daemon.json 
{
  "registry-mirrors": ["https://834kie09.mirror.aliyuncs.com"],
  "insecure-registry": ["172.16.16.3:5000"]
}

 

0x03 修改docker.service配置

在docker的docker.service文件内,新增私有镜像源信息(在K8S被所有节点进行此操作)

vm01@root:~$ cat /lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry 172.16.16.3:5000
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s

# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity

# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity

# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes

# kill only the docker process, not all processes in the cgroup
KillMode=process

[Install]
WantedBy=multi-user.target

 

0x04 重启docker服务

重启各个节点的docker服务,加载新的配置文件

systemctl daemon-reload
systemctl restart docker

在节点验证私有源的push和pull操作

docker push 172.16.16.3:5000/nginx_ss:v1.2
docker pull   172.16.16.3:5000/nginx_ss:v1.2

 

标签:systemd,5000,http,16.3,registry,https,172.16,docker
来源: https://www.cnblogs.com/JetpropelledSnake/p/16636807.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有