1.准备环境 1.1配置ip地址 xserver1: 192.168.100.11 xserver2: 192.168.100.12 1.2配置yum源 1.2.1xserver1配置yum源 1.挂载centos 1.挂载centos镜像 [root@localhost ~]# mkdir /opt/centos [root@localhost ~]# mount CentOS-7-x86_64-DVD-1511.iso /opt/centos 2.解压docker [root@localhost ~]# tar -zxvf Docker.tar.gz 3.配置yum源 [root@localhost ~]# rm -fr /etc/yum.repos.d/* [root@localhost ~]# cat >> /etc/yum.repos.d/local.repo << EOF [centos] name=centos baseurl=file:///opt/centos gpgcheck=0 [docker] name=docker baseurl=file:///opt/Docker gpgcheck=0 EOF 4.配置ftp服务 4.1 xserver1安装vsftpd [root@localhost ~]# yum install -y vsftpd 4.2 配置vsftpd.conf,并重启 [root@localhost ~]# vim /etc/vsftpd/vsftpd.conf 在文件中添加如下行: anon_root=/opt [root@localhost ~]# systemctl restart vsftpd 4.3 xserver2配置yum源 [root@localhost ~]# rm -fr /etc/yum.repos.d/* [root@localhost ~]# vi /etc/yum.repos.d/local.repo name=centos [centos] name=centos baseurl=ftp://192.168.100.11/centos gpgcheck=0 [docker] name=docker baseurl=ftp://192.168.100.11/Docker gpgcheck=0 5.两台主机安装docker 5.1安装docker xserver1和xserver2上均需安装docker [root@localhost ~]# yum install docker-ce -y 5.2 启动docker xserver1和xserver2均需启动docker [root@localhost ~]# systemctl daemon-reload [root@localhost ~]# systemctl start docker 6 xserver1部署镜像仓库 6.1上传镜像 我们可以直接运行/image.sh脚本,一次上传全部镜像,也可以根据需要上传单个镜像。 [root@localhost ~]# docker load -i /root/images/registry_latest.tar 上传之后,可以使用docker images查看本地镜像 [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 540a289bab6c 2 years ago 126MB registry latest f32a97de94e1 3 years ago 25.8MB 6.2创建仓库容器 使用如下命令,在xserver1上启动容器 [root@localhost ~]# docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry:latest 6.3修改daemon.json文件 [root@localhost ~]# vi /etc/docker/daemon.json 添加如下内容: {"insecure-registries":["192.168.100.11:5000"]} 重启docker [root@localhost ~]# systemctl restart docker 在xserver2上面也需要修改daemon.json文件,并重启docker 6.4标记镜像 [root@localhost ~]# docker tag nginx:latest 192.168.100.11:5000/nginx:latest 6.5上传镜像 [root@localhost ~]# docker push 192.168.100.11:5000/nginx:latest 7.xserver2 拉取镜像 7.1拉取镜像 [root@localhost ~]# docker pull 192.168.100.11:5000/nginx:latest 7.2查看结果 [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE 192.168.100.11:5000/nginx latest 540a289bab6c 2 years ago 126MB
标签:仓库,192.168,镜像,docker,root,localhost,latest From: https://www.cnblogs.com/xiaobaige/p/16928284.html