`
corejava2008
  • 浏览: 296611 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Docker本地私有仓库搭建

阅读更多

Docker本地私有仓库搭建:

准备两台服务器192.168.10.123,192.168.10.124

 

1.以容器的方式运行registry服务,在123服务器执行

docker run -idt -p 5000:5000 --name registry -v /data/registry:/data/docker/registry registry

 

启动成功后,使用docker ps查看进程

[root@localhost build]# docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                    NAMES
63a8ef84f969        registry            "docker-registry"      30 minutes ago      Up 30 minutes       0.0.0.0:5000->5000/tcp   registry             
f769894476dd        docker.io/redis     "/entrypoint.sh redi   About an hour ago   Up About an hour    6379/tcp                 serene_jones         
13f2081c739c        docker.io/redis     "/entrypoint.sh redi   About an hour ago   Up About an hour    6379/tcp                 distracted_pasteur   
7458914dbedf        docker.io/redis     "/entrypoint.sh redi   About an hour ago   Up About an hour    6379/tcp                 determined_poincare  
4a48ec12cbb7        docker.io/redis     "/entrypoint.sh redi   About an hour ago   Up About an hour    6379/tcp                 determined_cori 

 2.切换到124服务器

    从官方仓库下载Redis镜像

    并推送到本地仓库中

[root@localhost docker]# docker pull docker.io/redis
latest: Pulling from docker.io/redis
9d3ceacde91b: Pull complete 
bbe78c1a5a53: Pull complete 
9bce9474876b: Pull complete 
047a294381b2: Pull complete 
2658b5be63c6: Pull complete 
7bf6d72c51dd: Pull complete 
6d6a6cf52058: Pull complete 
aa2530999d9d: Pull complete 
e1826fa7683c: Pull complete 
6f363001266d: Pull complete 
836d921b3cd8: Pull complete 
2a7c655ad485: Pull complete 
24968be6ba8d: Pull complete 
61ccddfbf92f: Pull complete 
e352ded77489: Pull complete 
43d77a7c6a43: Pull complete 
9216d5a4eec8: Already exists 
docker.io/redis:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:ab962e0e648f99bd328dcca1ef0bef2da2f896fa7404d963a90a1308ef6235cc
Status: Downloaded newer image for docker.io/redis:latest

 

修改/etc/sysconfig/docker配置文件,添加--insecure-registry参数

[root@localhost docker]# cat /etc/sysconfig/docker
# /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --insecure-registry 192.168.100.123:5000'

DOCKER_CERT_PATH=/etc/docker

 

重启124服务器上的Docker服务

 

[root@localhost docker]# systemctl restart docker
[root@localhost docker]# systemctl status docker
docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
  Drop-In: /usr/lib/systemd/system/docker.service.d
           └─flannel.conf
   Active: active (running) since Mon 2015-09-07 12:20:33 CST; 1min 39s ago
     Docs: http://docs.docker.com
 Main PID: 6010 (docker)
   CGroup: /system.slice/docker.service
           └─6010 /usr/bin/docker -d --selinux-enabled --insecure-registry 192.168.100.12333:5000 --bip=172.17.2.1/24 --mtu=1472


 3.Tag镜像并推送到本地仓库

[root@localhost docker]# docker images
REPOSITORY                         TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
docker.io/redis                    latest              9216d5a4eec8        13 days ago         109.3 MB

[root@localhost docker]# docker tag docker.io/redis 192.168.100.123:500/qx/redis


[root@localhost docker]# docker images
REPOSITORY                         TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
192.168.100.123:5000/qeeka/redis   latest              9216d5a4eec8        13 days ago         109.3 MB
docker.io/redis                    latest              9216d5a4eec8        13 days ago         109.3 MB

 

[root@localhost docker]# docker push 192.168.100.123:5000/qx/redis
The push refers to a repository [192.168.100.123:5000/qx/redis] (len: 1)
Sending image list
Pushing repository 192.168.100.123:5000/qx/redis (1 tags)
9d3ceacde91b: Image successfully pushed 
bbe78c1a5a53: Image successfully pushed 
9bce9474876b: Image successfully pushed 
047a294381b2: Image successfully pushed 
2658b5be63c6: Image successfully pushed 
7bf6d72c51dd: Image successfully pushed 
6d6a6cf52058: Image successfully pushed 
aa2530999d9d: Image successfully pushed 
e1826fa7683c: Image successfully pushed 
6f363001266d: Image successfully pushed 
836d921b3cd8: Image successfully pushed 
2a7c655ad485: Image successfully pushed 
24968be6ba8d: Image successfully pushed 
61ccddfbf92f: Image successfully pushed 
e352ded77489: Image successfully pushed 
43d77a7c6a43: Image successfully pushed 
9216d5a4eec8: Image successfully pushed 
Pushing tag for rev [9216d5a4eec8] on {http://192.168.100.123:5000/v1/repositories/qx/redis/tags/latest}

 

0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics