其他分享
首页 > 其他分享> > 记录安装harbor

记录安装harbor

作者:互联网

安装harbor记录 官方文档

  1. 安装docker
  2. 安装docker-compose
  3. 下载安装所需要的版本 harbor

记录配置

  1. 配置docker

/etc/docker/daemon.json

{
    "insecure-registries": ["https://<YOUR HOSTNAME>"]
}

/usr/lib/systemd/system/docker.service 追加 --insecure-registry

# ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock 
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock  --insecure-registry https://xxx
  1. 配置harbor

harbor.yml

hostname =<YOUR HOSTNAME>
http:
  port: 80

https:
  port: 443
  certificate: /xxx
  private_key: /xxx

每次修改配置文件后都需要运行 prepare

  1. ./prepare

  2. ./install.sh

  1. docker-compose常用管理命令
停止服务: docker-compose stop
开始服务: docker-compose start
重启服务:docker-compose restart
停止服务并删除容器:docker-compose down
启动服务并运行容器:docker-compose up

安装记录:
 sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

 sudo chmod +x /usr/local/bin/docker-compose

 sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
 docker-compose -v

  1. 自签证书

修改'lcl.harbor.com'为自己的域名即可

openssl genrsa -out ca.key 4096
openssl req -x509 -new -nodes -sha512 -days 3650 \
 -subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=lcl.harbor.com" \
 -key ca.key \
 -out ca.crt
openssl genrsa -out lcl.harbor.com.key 4096
openssl req -sha512 -new \
    -subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=lcl.harbor.com" \
    -key lcl.harbor.com.key \
    -out lcl.harbor.com.csr
cat > v3.ext <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names

[alt_names]
DNS.1=lcl.harbor.com
DNS.2=lcl.harbor
DNS.3=os-1
EOF
openssl x509 -req -sha512 -days 3650 \
    -extfile v3.ext \
    -CA ca.crt -CAkey ca.key -CAcreateserial \
    -in lcl.harbor.com.csr \
    -out lcl.harbor.com.crt
cp lcl.harbor.com.crt /data/cert/
cp lcl.harbor.com.key /data/cert/
openssl x509 -inform PEM -in lcl.harbor.com.crt -out lcl.harbor.com.cert
mkdir -p /etc/docker/certs.d/lcl.harbor.com/
cp lcl.harbor.com.cert /etc/docker/certs.d/lcl.harbor.com/
cp lcl.harbor.com.key /etc/docker/certs.d/lcl.harbor.com/
cp ca.crt /etc/docker/certs.d/lcl.harbor.com/
systemctl restart docker

标签:compose,记录,harbor,安装,key,docker,com,lcl
来源: https://www.cnblogs.com/xiaoli-ya/p/16139577.html