一、Harbor安装
这里采用原生方式进行安装:
- 下载
wget https://github.com/goharbor/harbor/releases/download/v2.6.0/harbor-offline-installer-v2.6.0.tgz
- 解压
tar -xzvf harbor-offline-installer-v2.6.0.tgz -C /usr/local/
- 配置
复制一份配置文件:
cp harbor.yml.tmpl harbor.yml
编辑harbor.yml文件:
- 启动harbor
./install.sh
启动完毕后通过 http://172.16.52.10 进行登录即可:
二、Harbor使用
(一)创建项目
1、创建用户
2、创建私有项目
3、给项目追加用户
4、切换用户
(二)发布镜像到Harbor
对于发布到harbor的镜像有名称的要求,必须满足: harbor地址/项目名/镜像名:版本
1、修改daemon.json
该文件中配置支持的Docker仓库,然后重启Docker:
vi /etc/docker/daemon.json
{ "registry-mirrors": ["https://lhjmkjg1.mirror.aliyuncs.com"], "insecure-registries":["172.16.52.10:80"] # harbor仓库 }
然后重启Docker:
systemctl restart docker
2、登录harbor
然后需要在服务器上登录到harbor,这样才能进行推送镜像的操作:
# docker login -u 用户名 -p 密码 Harbor地址 [root@localhost web_test]# docker login -u shenjianping -p ****** 172.16.52.10:80 WARNING! Using --password via the CLI is insecure. Use --password-stdin. 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
3、制作镜像
docker build -t 172.16.52.10:80/repo/flask_demo:v1.0.0 .
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
FROM python:latest RUN mkdir -p /usr/loacal/app RUN mkdir -p ~/.pip COPY ./pip.conf ~/.pip RUN pip install flask COPY ./* /usr/local/app/ WORKDIR /usr/local/appDockerfile
查看镜像:
[root@localhost ~]# docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE 172.16.52.10:80/repo/flask_demo v1.0.0 87b8c32bbba2 About a minute ago 928MB
4、推送镜像
root@localhost ~]# docker push 172.16.52.10:80/repo/flask_demo:v1.0.0 The push refers to repository [172.16.52.10:80/repo/flask_demo] 809ad7146176: Pushed 751bb0b18024: Pushed 6832292f3b85: Pushed d8e325cd72bc: Pushed 14e9640b85c8: Pushed db8d0fe6cf95: Pushed 00901a4c6fc7: Pushed 7e7decd61f68: Pushed aedcb370b058: Pushed c3a0d593ed24: Pushed 26a504e63be4: Pushed 8bf42db0de72: Pushed 31892cc314cb: Pushed 11936051f93b: Pushed v1.0.0: digest: sha256:91e644b858659c3c2c425767ababba33e4a94e38439b0cb1df80096c4cfdf63a size: 3259
查看仓库:
如果是推送已有镜像,只需要修改镜像名称即可,通过命令:
docker tag demo:v1.0.0 192.16.52.10:80/repo/demo:v1.0.0
(三)拉取镜像
1、配置daemon.json
该文件中配置支持的Docker仓库,然后重启Docker:vi /etc/docker/daemon.json
{ "registry-mirrors": ["https://lhjmkjg1.mirror.aliyuncs.com"], "insecure-registries":["172.16.52.10:80"] # harbor仓库 }
2、拉取镜像
docker pull 172.16.52.10:80/repo/flask_demo:v1.0.0
标签:镜像,Harbor,52.10,Pushed,使用,harbor,docker,安装,80 From: https://www.cnblogs.com/shenjianping/p/16703484.html