本文主要是介绍第三十八天,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
第八周 周四
早
pip修改镜像源
查看python版本
python --version
安装pip
yum -y install python-pip
指定版本更新pip
[root@docker1 ~]# pip install --upgrade pip==20.3 -i https://mirrors.aliyun.com/pypi/simple [root@docker1 ~]# pip install docker-compose --ignore-installed requests -i https://mirrors.aliyun.com/pypi/simple #确保docker-compose 版本 1.26.2 (大于1.18即可)
安装docker
上传包,解压
[root@docker1 ~]# sh docker.sh [root@docker1 ~]# tar -zxvf harbor-offline-installer-v2.11.1.tgz [root@docker1 ~]# ls anaconda-ks.cfg docker.sh harbor harbor-offline-installer-v2.11.1.tgz
进入harbor目录修改配置文件
[root@docker1 ~]# cd harbor/ [root@docker1 harbor]# cp harbor.yml.tmpl harbor.yml [root@docker1 harbor]# ls common.sh harbor.yml install.sh prepare harbor.v2.11.1.tar.gz harbor.yml.tmpl LICENSE [root@docker1 harbor]# vim harbor.yml hostname: 192.168.1.24 #修改域名为本机ip地址 #注意:若没有https服务,需要将配置文件中所有https相关内容注释
配置docker镜像源
执行harbor脚本
[root@docker1 harbor]# vim /etc/docker/daemon.json {"registry-mirrors": ["https://do.nark.eu.org","https://dc.j8.work","https://docker.m.daocloud.io","https://dockerproxy.com","https://docker.mirrors.ustc.edu.cn","https://docker.nju.edu.cn"],"hosts": ["tcp://0.0.0.0:2375","unix:///var/run/docker.sock"],"insecure-registries":["http://192.168.1.24"] } [root@docker1 harbor]# vim /usr/lib/systemd/system/docker.service ..... ExecStart=/usr/bin/dockerd #删除后面多余的内容 ..... [root@docker1 harbor]# systemctl daemon-reload #加载docker配置文件 [root@docker1 harbor]# systemctl restart docker #重启 [root@docker1 harbor]# ./prepare [root@docker1 harbor]# ./install.sh #执行脚本,启动获取harbor所需容器
浏览器访问harbor(直接访问ip即可)
注意: 若出现80端口无法连接问题,网页发布在443端口,执行以下命令
[root@docker1 harbor]# docker-compose down [root@docker1 harbor]# ./prepare [root@docker1 harbor]# ./install.sh [root@docker1 harbor]# docker ps --all #发现nginx恢复80端口即可,若实在无法恢复,访问时加上端口号
登录
[root@docker1 harbor]# docker login http://192.168.1.24 Username: admin Password: WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded
上传镜像
-
打标签
docker tag centos:latest 192.168.1.24:/library/centos:v0
-
上传
[root@docker1 harbor]# docker push 10.0.0.51/library/centos:v0
使用到的docker-compose命令
# 一次性关闭所有容器 [root@docker1 harbor]# docker-compose stop # 开启所有容器 [root@docker1 harbor]# docker-compose start # 删掉所有容器 [root@docker1 harbor]# docker-compose down # 重新检查环境
在其他docker主机上配置daemon仓库,启动docker,使用复制的下载链接,添加共享的镜像
[root@node11 ~]# vim /etc/docker/daemon.json "insecure-registries" : [ "http://10.0.0.51" ], [root@node11 ~]# systemctl daemon-reload [root@node11 ~]# systemctl restart docker [root@node11 ~]# docker pull 10.0.0.51/library/centos@sha256:a1801b843b1bfaf77c501e7a6d3f709401a1e0c838630 37fa3aab063a7fdb9dc 10.0.0.51/library/centos@sha256:a1801b843b1bfaf77c501e7a6d3f709401a1e0c838630 37fa3aab063a7fdb9dc: Pulling from library/centos Digest: sha256:a1801b843b1bfaf77c501e7a6d3f709401a1e0c83863037fa3aab063a7fdb9dc Status: Downloaded newer image for 10.0.0.51/library/centos@sha256:a1801b843b1bfaf77c501e7a6d3f709401a1e0c838630 37fa3aab063a7fdb9dc 10.0.0.51/library/centos@sha256:a1801b843b1bfaf77c501e7a6d3f709401a1e0c838630 37fa3aab063a7fdb9dc [root@node11 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos latest 5d0da3dc9764 2 years ago 231MB 10.0.0.51/library/centos <none> 5d0da3dc9764 2 years ago 231MB
这篇关于第三十八天的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!