harbor私有仓库安装
准备环境
centos7.4
docker-ce 19.03.8
docker-compose version 1.18.0
harbor 版本: 1.7.5
一、安装dokcer
# 安装依赖包 yum install -y yum-utils device-mapper-persistent-data lvm2 # 添加Docker软件包源 yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo # 安装Docker CE yum install -y docker-ce # 启动Docker服务并设置开机启动 systemctl start docker systemctl enable docker #镜像加速 curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
二、harbor安装
docker-compose 版本 :https://github.com/docker/compose/releases/
harbor版本:https://github.com/vmware/harbor/releases
docker-compose
docker-compose 是可执行文件所以可以直接移动
#将docker-compose移至/usr/bin/docker-compose目录 mv docker-compose-Linux-x86_64 /usr/bin/docker-compose #执行docker-compose测试 docker-compose
harbor
#解压 tar -zxvf harbor-offline-installer-v1.7.5.tgz #配置IP或者域名 cd harbor vim harbor.cfg ... hostname = 10.0.0.100 ... #安装 ./install.sh
出现下面字样就说明OK了
Creating network "harbor_harbor" with the default driver Creating harbor-log ... done Creating harbor-adminserver ... done Creating registry ... done Creating harbor-db ... done Creating redis ... done Creating registryctl ... done Creating harbor-core ... done Creating harbor-portal ... done Creating harbor-jobservice ... done Creating nginx ... done ✔ ----Harbor has been installed and started successfully.---- Now you should be able to visit the admin portal at http://10.0.0.100. For more details, please visit https://github.com/goharbor/harbor .
三、访问Web
admin
Harbor12345
四、添加主机信任
#内容如下 [root@localhost harbor]# cat /etc/docker/daemon.json {"registry-mirrors": ["http://f1361db2.m.daocloud.io"], "insecure-registries": ["10.0.0.100"] }
重启docker生效
systemctl restart docker
五、推送测试
登录账户
[root@localhost ]# docker login 10.0.0.100 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
创建Dockerfile
FROM centos:7 LABEL maintainer wenlong RUN yum install java-1.8.0-openjdk wget curl unzip iproute net-tools -y && \ yum clean all && \ rm -rf /var/cache/yum/* RUN wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.23/bin/apache-tomcat-8.5.23.tar.gz && \ tar -zxvf apache-tomcat-8.5.23.tar.gz && \ mv apache-tomcat-8.5.23 /usr/local/tomcat && \ rm -rf /usr/local/tomcat/webapps/* && \ rm -rf /root/apache-tomcat-8.5.23* && \ mkdir -p /usr/local/tomcat/webapps/xuewenlong && \ echo "ok" > /usr/local/tomcat/webapps/xuewenlong/status.html && \ sed -i '1a JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom"' /usr/local/tomcat/bin/catalina.sh && \ ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime ENV PATH $PATH:/usr/local/tomcat/bin WORKDIR /usr/local/tomcat EXPOSE 8080 CMD ["catalina.sh", "run"]
构建镜像
docker build -t tomcat:v1 -f /home/wenlong/docker/Dockerfile-tomcat . #查看构建的镜像 docker images |grep tomcat tomcat v1 c30b1f0f5cfa 12 minutes ago 444MB
打标签
docker tag tomcat:v1 10.0.0.100/library/tomcat:v1
上传镜像
[root@localhost docker]# docker push 10.0.0.100/library/tomcat:v1 The push refers to repository [10.0.0.100/library/tomcat] 84978778128d: Pushed 022b3c854a6f: Pushed edf3aa290fb3: Pushed v1: digest: sha256:e80c965b612e57bbd879ed78c9c5f64c427c9bbe8e3dac03902a5efbc73e00bd size: 953
下载镜像
docker pull 10.0.0.100/library/tomcat:v1