准备
server1,server2 (其中server1作为私有库服务器,server2作为普通客户端)
(相关推荐:docker教程)
在server1上
1、下载 registry
1
docker pull registry:latest
2、配置 /etc/default/docker 因为https需要证书密码等比较复杂,直接加 insecure-registry即可
1
2
3
4
5
6
7
8
9
10
11
12
13
# Docker Upstart and SysVinit configuration file
# Customize location of Docker binary (especially for development testing).
#DOCKER="/usr/local/bin/docker"
# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
DOCKER_OPTS="--insecure-registry 127.0.0.1:5000"
# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"
# This is also a handy place to tweak where Docker's temporary files go.
#export TMPDIR="/mnt/bigdrive/docker-tmp"
3、启动registry
1
sudo docker run --name registry -d -p 5000:5000 -v /home/docker_registry:/var/lib/registry --restart=always registry:latest
4、tag镜像
1
docker tag redis server1:5000/redis
5、推送保存私有镜像
1
docker push server1:5000/redis
5.1、查看推送到私有仓库的镜像
1
2
3
4
5
6
$ docker search 10.10.105.71:5000/tonybai/busybox/
Error response from daemon: Unexpected status code 404
但通过v2版本的API,我们可以实现相同目的:
$curl http://10.10.105.71:5000/v2/_catalog
{"repositories":["tonybai/busybox"]}
在server2(client)上
因为docker Registry中讲到, 如果采用insecure registry的模式,那么所有与Registry交互的主机上的Docker Daemon都要配置:–insecure-registry选项。除了这个模式还可以配置证书,在此不作说明
1、配置 -insecure-registry(centos:/etc/sysconfig/docker ubuntu:/etc/default/docker)
1
2
3
4
5
6
7
8
9
10
11
12
13
# Docker Upstart and SysVinit configuration file
# Customize location of Docker binary (especially for development testing).
#DOCKER="/usr/local/bin/docker"
# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
DOCKER_OPTS="--insecure-registry server1:5000"
# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"
# This is also a handy place to tweak where Docker's temporary files go.
#export TMPDIR="/mnt/bigdrive/docker-tmp"
2、下载
1
docker pull server1:5000/redis
3、提交推送
1
2
3
docker tag redis server1:5000/redis
docker push server1:5000/redis
相关文章
- 01-11Docker使用阿里云加速|建立私有库registry
- 01-11Harbor搭建企业级私有库(权威测试)
- 01-11springcloud-alibaba学习笔记(六)docker搭建seata测试环境和(file模式)配置seata-server的地址
- 01-11厉害了,如何搭建一套自己的私有网盘?
- 01-11手把手教你搭建自己的Angular组件库 - DevUI
- 01-11docker下的arangodb 数据库导入导出的的shell脚本,在tar包中提供了一个协助倒入的脚本
- 01-11docker-compose.yml方式搭建好测试环境的TiDB
- 01-11使用 Docker 搭建你的Wiki(DokuWiki)
- 01-11OpenShift 3 : 基于Docker的私有PaaS平台
- 01-11docker搭建自己的Lnmp环境+宝塔