Docker私有仓库搭建

1 下载

   sudo docker pull registry

2 启动容器

   sudo docker run -d -p 5000:5000 registry

2.1 制定挂载目录

  sudo docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry registry

3测试

  sudo docker pull busybox

4 接下来修改一下该镜像的tag。

 sudo docker tag busybox localhost:5000/busybox

5接下来把打了tag的镜像上传到私有仓库。

 sudo docker push localhost:5000/busybox

6 push到私有仓库

 sudo docker push localhost:5000/busybox

7 从私有仓库获取镜像

sudo docker pull localhost:5000/busybox

8 使用docker search
命令:
# docker search registry_ip:5000/

如果要查询仓库中指定账户下的镜像,则使用如下命令:
# docker search registry_ip:5000/account/

9 查看镜像

curl -XGET http://registry:5000/v2/_catalog

curl -XGET http://registry:5000/v2/image_name/tags/list

10 根据Dockfile构建镜像

docker build -t "zingdocker/jdk-tomcat" .   
docker run -d -p 8090:8080 zingdocker/jdk-tomcat  

docker build -t (tagName) (Dockerfile Directory)

11 报错解决办法:

  Error response from daemon: Get https://10.10.239.222:5000/v1/_ping: http: server gave HTTP response to HTTPS client

  只需要两步即可:

  1,Create or modify /etc/docker/daemon.json

  [root@localhost ~]# echo '{ "insecure-registries":    ["10.10.239.222:5000"] }' > /etc/docker/daemon.json
  [root@localhost ~]# cat /etc/docker/daemon.json
  { "insecure-registries":["10.10.239.222:5000"] }
  
    2,重载docker
  root@localhost ~]# systemctl restart docker

你可能感兴趣的:(Docker私有仓库搭建)