创建docker仓库:

开启docker:service docker start

下载仓库镜像:docker pull registry

创建镜像文件夹:mkdir -p /opt/data/registry

开启仓库镜像,并将镜像目录挂在到我们自己创建的目录,镜像端口5000:docker run -d -p 5000:5000 -v /opt/data/registry:/var/lib/registry --name private_registry registry

编辑配置文件:vi /etc/default/docker

重启docker并开启镜像:service docker restart

docker start private_registry

设置开机自动启动docker:systemctl enable docker

设置自动启动仓库镜像:docker update --restart=always private_registry

进入容器 docker exec -it private_registry /bin/sh

使用docker镜像仓库:

修改tag:docker tag 镜像名 xxx.xxx.xxx.xxx5000/root/test

修改配置文件使用https:vi /etc/docker/daemon.json

"insecure-registries": [ "xxx.xxx.xxx.xxx:5000"]

修改后要重启docker服务

#systemctl daemon-reload

#systemctl restart docker

curl -X GET http://xxx.xxx.xxx.xxx:5000/v2/_catalog

查询版本库中已有的镜像

curl -X GET http://xxx.xxx.xxx.xxx:5000/v2/centos_ssserver/tags/list

查看某个镜像的版本

上传镜像:docker push xxx.xxx.xxx.xxx:5000/centos_ssserver:V1

下载镜像:docker pull xxx.xxx.xxx.xxx:5000/centos_ssserver:V1

删除镜像:

第一步:registry启动依赖config.yml配置文件:在默认文件的storage区域中添加delete_enable_ture配置项。也可以在启动时候指定-e添加。允许删除镜像:

配置文件:

Docker个人学习-LMLPHP

查询要删除的镜像ID

curl -v --silent -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -X GET  http://xxx.xxx.xxx.xxx:5000/v2/centos_ssserver/manifests/V2 2>&1 | grep Docker-Content-Digest | awk '{print ($3)}'

删除

curl -v --silent -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -X DELETE http://xxx.xxx.xxx.xxx:5000/v2/centos_ssserver/manifests/sha256:(刚刚查询到的ID)

制作本地镜像(废弃):

#tar --numeric-owner --exclude=/proc --exclude=/sys -cvf centos7.5-base.tar /

#cat centos7.5-base.tar | docker import - centos7.5-base

装机:

  1. 安装docker:yum install docker
  2. 修改配置文件使用https:vi /etc/docker/daemon.json

添加:"insecure-registries": ["xxx.xxx.xxx.xxx:5000"]

  1. 启动docker服务:systemctl start docker(可以设置docker自动启动 systemctl enable docker)
  2. 下载镜像 docker pull xxx.xxx.xxx.xxx:5000/centos_ssserver:V2
  3. 运行docker镜像

docker run -d -v /ftpserver/Monitor/Folder:/ftpserver/Monitor/Folder -v /var/log:/var/log -p 1200-1207:1200-1207 -p 1200-1207:1200-1207/udp -p 21:21 -p 21:21/udp 119.3.72.25:5000/centos_ssserver:V2

修改hostname:curl -sSL 119.3.72.25/changename.sh|bash -s [hostname]

卸载docker

yum remove docker \

                  docker-client \

                  docker-client-latest \

                  docker-common \

                  docker-latest \

                  docker-latest-logrotate \

                  docker-logrotate \

                  docker-selinux \

                  docker-engine-selinux \

                  docker-engine

rm -rf /etc/systemd/system/docker.service.d

rm -rf /var/lib/docker

rm -rf /var/run/docker

02-26 21:08