小信 2020-05-14
# 安装依赖包 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
#将docker-compose移至/usr/bin/docker-compose目录 mv docker-compose-Linux-x86_64 /usr/bin/docker-compose #执行docker-compose测试 docker-compose
#解压 tar -zxvf harbor-offline-installer-v1.7.5.tgz #配置IP或者域名 cd harbor vim harbor.cfg ... hostname = 10.0.0.100 ... #安装 ./install.sh
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 .
admin Harbor12345
#内容如下 [ harbor]# cat /etc/docker/daemon.json {"registry-mirrors": ["http://f1361db2.m.daocloud.io"], "insecure-registries": ["10.0.0.100"] }
systemctl restart docker
[ ]# 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
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
[ 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