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"]