docker推送镜像到harbor镜像库

1、Harbor

(1)Harbor新建私有/公开项目

(2)进入项目---成员---添加用户、分配权限等级

2、docker

2.1 配置 registry 私库相关的参数

 "registry-mirrors": 私库加速器

"insecure-registries": 私库的服务地址

[root@100-020-gpuserver ~]# cat /etc/docker/daemon.json
{
  "registry-mirrors": ["https://dockerhub.azk8s.cn", "https://docker.mirrors.ustc.edu.cn"],
  "insecure-registries": ["registry.***.com:8000"],
  "max-concurrent-downloads": 10,
  "log-driver": "json-file",
  "log-level": "warn",
  "log-opts": {
    "max-size": "50m",
    "max-file": "3"
    },
  "data-root": "/data",
  "bip": "192.168.100.1/24",
  "runtimes": {
        "nvidia": {
            "path": "/usr/bin/nvidia-container-runtime",
            "runtimeArgs": []
        }
    }
}

2.2 重启docker

[root@100-020-gpuserver PersonEval_offline]# systemctl restart docker

2.3 登录

[root@100-020-gpuserver PersonEval_offline]# docker login registry.***.com:8000
Username: ****
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

2.4 推送

(1)在项目中标记镜像

# SOURCE_IMAGE为docker images查询到的IMAGE ID
# project为Harbor所建的项目
# REPOSITORY[:TAG]为推送的镜像在仓库的名称及tag
[root@100-020-gpuserver PersonEval_offline]# docker tag SOURCE_IMAGE registry.***.com:8000/project/REPOSITORY[:TAG]

(2)推送镜像到项目

# project为Harbor所建的项目
# REPOSITORY[:TAG]为推送的镜像在镜像仓库的名称及tag,与上条命令对应
[root@100-020-gpuserver PersonEval_offline]# docker push registry.***.com:8000/project/REPOSITORY[:TAG]

(3)删除标记镜像

# REPOSITORY[:TAG]为推送的镜像在镜像仓库的名称及tag,docker images可获取
[root@100-020-gpuserver PersonEval_offline]# docker rmi REPOSITORY[:TAG]

2.5 拉取镜像(未连接外网,从私库拉取centos7-python3配置镜像)

(1)命令行

[root@172-18-80-39 spem]$ docker pull registry.***.com:8000/project/centos7-python3:v3.6

(1)dockerfile拉取centos/python镜像

[root@172-18-80-39 spem]$ cat dockerfile
FROM registry.***.com:8000/project/centos7-python3:v3.6
RUN mkdir -p /usr/src/spem
WORKDIR /usr/src/spem
#可以通过requirements.txt文件安装,方法见https://blog.csdn.net/Mugo_Moon/article/details/114981204
#建议安装低版本django,以免系统带的SQLite版本无法使用
RUN pip3 install -i http://pypi.yingzi.com/simple --trusted-host pypi.yingzi.com --default-timeout=1000 django==2.1.8
RUN pip3 install -i http://pypi.yingzi.com/simple --trusted-host pypi.yingzi.com --default-timeout=1000 uwsgi
RUN ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi
COPY . /usr/src/spem
#CMD ["uwsgi", "--ini", "/usr/src/spem/uwsgi/uwsgi.ini"]
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值