一、搭建私有仓库

#环境

Ip 192.168.0.34

X86云主机

[root@lh- /]# uname -a
Linux lh- 3.10.-327.13..el7.x86_64 # SMP Thu Mar :: UTC x86_64 x86_64 x86_64 GNU/Linux

操作系统

[root@lh- data]# cat /etc/redhat-release
CentOS Linux release 7.2. (Core)

#拉registry镜像,运行一个容器

[root@lh- ~]# sudo docker pull registry
[root@lh- ~]# sudo docker run -d -p : -v /opt/data/registry:/tmp/registry registry

#拉busybox镜像,打标签

[root@lh- ~]# sudo docker pull busybox
[root@lh- ~]# sudo docker tag busybox 192.168.0.34:/busybox

#提交镜像到私有仓库

[root@lh- ~]#  sudo docker push 192.168.0.34:/busybox
The push refers to a repository [192.168.0.34:/busybox]
unable to ping registry endpoint https://192.168.0.34:5000/v0/
v2 ping attempt failed with error: Get https://192.168.0.34:5000/v2/: dial tcp 192.168.0.34:5000: getsockopt: connection refused
v1 ping attempt failed with error: Get https://192.168.0.34:5000/v1/_ping: dial tcp 192.168.0.34:5000: getsockopt: connection refused

因为Docker从1.3.x之后,与docker registry交互默认使用的是https,但是此处搭建私有仓库却只提供http服务,所以当和私有仓库交互时报上述错误。因此需要在启动docker server时增加启动参数为默认使用http访问。

#若无问题,直接查看仓库镜像

[root@lh- data]# curl -XGET 192.168.0.34:/v2/_catalog

二、FAQ

#上面push镜像是报错,docker配置文件中添加如下一行:

[root@lh- ~]# vi /etc/sysconfig/docker
# If you have a registry secured with https but do not have proper certs
# distributed, you can tell docker to not look for full authorization by
# adding the registry to the INSECURE_REGISTRY line and uncommenting it.
# INSECURE_REGISTRY='--insecure-registry'
INSECURE_REGISTRY='--insecure-registry=192.168.0.34:5000'

#重启docker服务

[root@lh- ~]# systemctl restart docker.service
Warning: docker.service changed on disk. Run 'systemctl daemon-reload' to reload units.
[root@lh- ~]# sudo docker push 192.168.0.34:/busybox
The push refers to a repository [192.168.0.34:/busybox]
Put http://192.168.0.34:5000/v1/repositories/busybox/: dial tcp 192.168.0.34:5000: getsockopt: connection refused

注:连接拒绝。报错后面可以看到是因为未启动容器,不过此时配置文件未生效。

[root@lh- ~]# ps -aux|grep docker
root 1.3 0.4 ? Ssl : : /usr/bin/docker-current daemon --exec-opt native.cgroupdriver=systemd --selinux-enabled --log-driver=journald --insecure-registry=192.168.0.34:
root 0.2 0.1 ? Sl : : docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port -container-ip 172.17.0.2 -container-port
root 0.0 0.0 pts/ S+ : : grep --color=auto docker

注:根据输出可以看出我们更改配置文件并没有生效

#修改docker配置文件,使其重启服务能生效

[root@lh- ~]# vi /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target rhel-push-plugin.socket
Wants=docker-storage-setup.service [Service]
Type=notify
NotifyAccess=all
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
ExecStart=/usr/bin/docker-current daemon \
--exec-opt native.cgroupdriver=systemd \
$OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$ADD_REGISTRY \
$BLOCK_REGISTRY \
$INSECURE_REGISTRY
LimitNOFILE=
LimitNPROC=
LimitCORE=infinity
TimeoutStartSec=
MountFlags=slave
Restart=on-abnormal [Install]
WantedBy=multi-user.target

#重启docker服务,查看修改配置是否写入

[root@lh- ~]# systemctl daemon-reload
[root@lh- ~]# systemctl restart docker
[root@lh- ~]# ps -aux|grep docker
root 2.8 0.3 ? Ssl : : /usr/bin/docker-current daemon --exec-opt native.cgroupdriver=systemd --selinux-enabled --log-driver=journald --insecure-registry=192.168.0.34:
root 0.5 0.2 ? Sl : : docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port -container-ip 172.17.0.2 -container-port
root 0.0 0.0 pts/ S+ : : grep --color=auto docker

#前面提交到私有仓库报错

[root@lh- ~]# sudo docker push 192.168.0.34:/busybox
The push refers to a repository [192.168.0.34:/busybox]
Put http://192.168.0.34:5000/v1/repositories/busybox/: dial tcp 192.168.0.34:5000: getsockopt: connection refused [root@lh- ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b57ed47acdc1 rancher/swarm-agent:v0.1.3 "swarm-agent" minutes ago Up minutes r-Swarm_swarm-agent_1
6cb333619b90 registry "/entrypoint.sh /etc/" hours ago Exited () About an hour ago pensive_lovelace
[root@lh- ~]# docker start 6cb333619b90
6cb333619b90
[root@lh- ~]# sudo docker push 192.168.0.34:/busybox
The push refers to a repository [192.168.0.34:/busybox]
8ac8bfaff55a: Pushed
latest: digest: sha256:a59906e33509d14c036c8678d687bd4eec81ed7c4b8ce907b888c607f6a1e0e6 size:

原因:未开启registry镜像容器。

#进入容器报错

[root@lh- ~]# docker exec -it 6cb333619b90 /bin/bash
exec: "/bin/bash": stat /bin/bash: no such file or directory

原因:不支持bash

#进入容器查看镜像存储

[root@lh- ~]# docker exec -it 6cb333619b90 /bin/sh
/ #
/ # ls
bin entrypoint.sh home linuxrc mnt root sbin sys usr
dev etc lib media proc run srv tmp var
/ # cd tmp/registry/
/tmp/registry # ls
/tmp/registry # ls
[root@lh- ~]# sudo docker run 192.168.0.34:/busybox
[root@lh- ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e7a80ce00dbe 192.168.0.34:/busybox "sh" seconds ago Exited () seconds ago [root@lh- ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE192.168.0.34:/busybox latest 2b8fd9751c4c weeks ago 1.093 MB

感觉写一起有些太长了,再来一篇吧

https://www.cnblogs.com/zeppelin/p/5906435.html

欢迎扫码关注下面公众号,定期分享大数据与知识图谱相关知识点,读书思考。

Docker私有仓库1的更多相关文章

  1. 一步步搭建docker私有仓库并从私有仓库中下载镜像

    一步步搭建docker私有仓库 #下载镜像 docker pull registry#查看镜像 docker images #运行私有仓库,指定端口和数据卷 docker run -d -p : -v ...

  2. 搭建docker私有仓库,建立k8s集群

    服务器IP角色分布 192.168.5.2 etcd server 192.168.5.2 kubernetes master 192.168.5.3 kubernetes node 192.168. ...

  3. docker 私有仓库镜像的存储位置

    docker 私有仓库的镜像 是存储在5739360d1030 registry "docker-registry" 3 days ago Up 28 hours 0.0.0.0: ...

  4. 在docker私有仓库如何查看有哪些镜像?

    搭建了docker私有仓库,上传了一些镜像,时间长了就会忘了有哪些镜像,在网上查了,有大佬是通过脚本查看的,多厉害! #!/usr/bin/env python#-*- coding:utf-8 -* ...

  5. 转载:教你分分钟搞定Docker私有仓库Registry

    一.什么是Docker私有仓库Registry 官方的Docker hub是一个用于管理公共镜像的好地方,我们可以在上面找到我们想要的镜像,也可以把我们自己的镜像推送上去.但是,有时候我们的服务器无法 ...

  6. Docker 私有仓库建立(加密和用户验证)

    (一)生成证书1.mkdir /certs2.cd /certs 3.生成自签名证书 sudo openssl req -newkey rsa:2048 -new -nodes -x509 -days ...

  7. 搭建docker私有仓库(https)

    1.修改openssl.cnf,支持IP地址方式,HTTPS访问在Redhat7或者Centos系统中,文件所在位置是/etc/pki/tls/openssl.cnf.在其中的[ v3_ca]部分,添 ...

  8. 搭建docker私有仓库

    保存镜像的地方成为仓库(registry).目前有2种仓库:公共仓库和私有仓库. 最方便的是使用公共仓库上传和下载镜像,下载不需要注册,上传需要到公共仓库注册.公共仓库网站:https://hub.d ...

  9. 教你分分钟搞定Docker私有仓库Registry

    一.什么是Docker私有仓库Registry 官方的Docker hub是一个用于管理公共镜像的好地方,我们可以在上面找到我们想要的镜像,也可以把我们自己的镜像推送上去.但是,有时候我们的服务器无法 ...

  10. docker 私有仓库简易搭建

    概要 本地私有仓库 局域网私有仓库 总结 概要 docker hub 使用非常方便,而且上面有大量的镜像可以使用. 但是,每次都远程下载镜像速度非常慢,如果能在本地做一个 docker 的仓库,多人协 ...

随机推荐

  1. 替换ubuntu 14.04的源

    1. 背景(为什么要替换)安装ubuntu,默认源是(http://extras.ubuntu.com/ubuntu),国内访问很慢...当我们用apt-get安装软件包或者更新时有时很慢,所以才想到 ...

  2. php中switch语句case后表达式写法记录一

    可作等级评价: $var = 95; switch(true){ case $var < 100; $level = 1; break; case $var < 95; $level = ...

  3. springmvc框架下ajax请求传参数中文乱码解决

    springmvc框架下jsp界面通过ajax请求后台数据,传递中文参数到后台显示乱码 解决方法:js代码 运用encodeURI处理两次 /* *掩码处理 */ function maskWord( ...

  4. windows 上搭建 sftp 服务器 --freesshd

    Linux 下 sftp 默认都会安装的, Windows 就没有了.网上搜的资料发现比较好用的是 freesshd,免费版中最好用的. 1,下载:http://www.freesshd.com/?c ...

  5. fpga串口通信

    ---恢复内容开始--- 1.波特率的计算公式:9600bps 是指每秒可以传输9600位 则一位需要的时间为1/9600 约等于0.000104 开发板晶振大小为50M则传输一位需要的时间为 0.0 ...

  6. iOS APP中Versions和build版本区别

    version是app发布时用户看到的版本号. build的为了方便开发者多次提交binary, 比如被苹果reject后. 例如,第一次提交version和build都是1.0. 假如审核没过,那么 ...

  7. Unity 解决 An asset is marked with HideFlags.DontSave but is included in the build 问题。

    问题是:不能使用Unity使用的默认的字体.想要显示中文直接去下载一个字体.没必要使用默认的字体

  8. bone collector hdu 01背包问题

    Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bone Collec ...

  9. jquery获取radio的值

    Html代码是 <label><input type="radio" name="proofing" value="1"& ...

  10. H264中的MapUnits

    1 MapUnits 在FMO(Flexible Macroblock ordering)时,从宏块到条带组的映射是以MapUnits为基本单位,MapUnits可能为宏块,也可能是上下两个宏块(见下 ...