公网ip |
内网eth0 ip |
角色 |
系统版本 |
180.76.150.184 |
172.18.0.111 |
master |
CentOS 7.3.1611 (Core) |
180.76.114.227 |
172.18.0.109 |
node1 |
CentOS 7.3.1611 (Core) |
180.76.164.183 |
172.18.0.110 |
node2 |
CentOS 7.3.1611 (Core) |
180.76.150.184 master搭建harbor仓库
安装 Harbor 需要先安装 docker 和 docker-compose
1.安装docker(已安装,略过)
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce
systemctl start docker
systemctl enable docker
2.安装docker-compose
curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
#安装命令补齐插件
yum install bash-completion
curl -L https://raw.githubusercontent.com/docker/compose/1.16.1/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
docker-compose version
3.安装Harbor
wget -P /usr/loca/src/ https://github.com/vmware/harbor/releases/download/v1.2.0/harbor-online-installer-v1.2.0.tgz
cd /usr/loca/src/
tar xvf harbor-online-installer-v1.2.0.tgz -C /usr/local/
cp /usr/local/harbor/harbor.cfg /usr/local/harbor/harbor.cfg.bak
#修改harbor配置文件
[root@instance-fq0043cl-3 harbor]# cat /usr/local/harbor/harbor.cfg
## Configuration file of Harbor
#The IP address or hostname to access admin UI and registry service.
#DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname = reg.kt007.com
#The protocol for accessing the UI and token/notification service, by default it is http.
#It can be set to https if ssl is enabled on nginx.
ui_url_protocol = http
#The password for the root user of mysql db, change this before any production use.
db_password = root123
#Maximum number of job workers in job service
max_job_workers = 3
#Determine whether or not to generate certificate for the registry's token.
#If the value is on, the prepare script creates new root cert and private key
#for generating token to access the registry. If the value is off the default key/cert will be used.
#This flag also controls the creation of the notary signer's cert.
customize_crt = off
#The path of cert and key files for nginx, they are applied only the protocol is set to https
ssl_cert = /data/cert/server.crt
ssl_cert_key = /data/cert/server.key
#The path of secretkey storage
secretkey_path = /data
#Admiral's url, comment this attribute, or set its value to NA when Harbor is standalone
admiral_url = NA
#The password of the Clair's postgres database, only effective when Harbor is deployed with Clair.
#Please update it before deployment, subsequent update will cause Clair's API server and Harbor unable to access Clair's database.
clair_db_password = password
#NOTES: The properties between BEGIN INITIAL PROPERTIES and END INITIAL PROPERTIES
#only take effect in the first boot, the subsequent changes of these properties
#should be performed on web ui
#************************BEGIN INITIAL PROPERTIES************************
#Email account settings for sending out password resetting emails.
#Email server uses the given username and password to authenticate on TLS connections to host and act as identity.
#Identity left blank to act as username.
email_identity =
email_server = smtp.exmail.qq.com
email_server_port = 25
email_username = wukang@lanjingshidai.com
email_password = 1qaz@WSX3edc
email_from = wukang@lanjingshidai.com
email_ssl = false
##The initial password of Harbor admin, only works for the first time when Harbor starts.
#It has no effect after the first launch of Harbor.
#Change the admin password from UI after launching Harbor.
harbor_admin_password = Harbor12345
##By default the auth mode is db_auth, i.e. the credentials are stored in a local database.
#Set it to ldap_auth if you want to verify a user's credentials against an LDAP server.
auth_mode = db_auth
#The url for an ldap endpoint.
ldap_url = ldaps://ldap.mydomain.com
#A user's DN who has the permission to search the LDAP/AD server.
#If your LDAP/AD server does not support anonymous search, you should configure this DN and ldap_search_pwd.
#ldap_searchdn = uid=searchuser,ou=people,dc=mydomain,dc=com
#the password of the ldap_searchdn
#ldap_search_pwd = password
#The base DN from which to look up a user in LDAP/AD
ldap_basedn = ou=people,dc=mydomain,dc=com
#Search filter for LDAP/AD, make sure the syntax of the filter is correct.
#ldap_filter = (objectClass=person)
# The attribute used in a search to match a user, it could be uid, cn, email, sAMAccountName or other attributes depending on your LDAP/AD
ldap_uid = uid
#the scope to search for users, 1-LDAP_SCOPE_BASE, 2-LDAP_SCOPE_ONELEVEL, 3-LDAP_SCOPE_SUBTREE
ldap_scope = 3
#Timeout (in seconds) when connecting to an LDAP Server. The default value (and most reasonable) is 5 seconds.
ldap_timeout = 5
#Turn on or off the self-registration feature
self_registration = off
#The expiration time (in minute) of token created by token service, default is 30 minutes
token_expiration = 30
#The flag to control what users have permission to create projects
#The default value "everyone" allows everyone to creates a project.
#Set to "adminonly" so that only admin user can create project.
project_creation_restriction = adminonly
#Determine whether the job service should verify the ssl cert when it connects to a remote registry.
#Set this flag to off when the remote registry uses a self-signed or untrusted certificate.
verify_remote_cert = on
#************************END INITIAL PROPERTIES************************
#############
/usr/local/harbor/install.sh
#查看安装的容器
docker-compose ps
浏览器访问http://180.76.150.184/
用户名admin
密码Harbor12345
#启动 Harbor
docker-compose start
#停止 Harbor
docker-compose stop
#重启 Harbor
docker-compose restart
登陆node2
vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd --insecure-registry 180.76.150.184
或者
cat > /etc/docker/daemon.json << EOF
{ "insecure-registries":["180.76.150.184"] }
EOF
systemctl restart docker
#登陆报错
docker login 180.76.150.184
Username: admin
Password:
Error response from daemon: Get http://180.76.150.184/v2/: Get http://reg.kt007.com/service/token?account=admin&client_id=docker&offline_token=true&service=harbor-registry: dial tcp: lookup reg.kt007.com on 172.18.0.3:53: no such host
#编辑host文件添加一下解析
vim /etc/hosts
180.76.150.184 reg.kt007.com
[root@instance-fq0043cl-1 ~]# docker login 180.76.150.184
Username: admin
Password:
Login Succeeded
docker tag nginx-04-17:latest 180.76.150.184/library/nginx-04-18:latest
docker push 180.76.150.184/library/nginx-04-18:latest
[root@instance-fq0043cl-1 ~]# docker push 180.76.150.184/library/nginx-04-18:latest
The push refers to a repository [180.76.150.184/library/nginx-04-18]
3a843e207168: Pushed
0b9e07febf57: Pushed
55028c39c191: Pushed
0a07e81f5da3: Pushed
latest: digest: sha256:f187bc4acffa323b8e07d57800f1fc46ba483d3c5748b90a3fba862ec0fb537a size: 1155
进入任意一台安装docker客户端的机器
#编辑host文件添加一下解析
vim /etc/hosts
180.76.150.184 reg.kt007.com
[root@ljsd-test-14 ~]# docker pull 180.76.150.184/library/nginx-04-18:latest
Trying to pull repository 180.76.150.184/library/nginx-04-18 ...
latest: Pulling from 180.76.150.184/library/nginx-04-18
6ae821421a7d: Downloading [====> ] 2.053 MB/22.5 MB
58702d4af197: Downloading [====> ] 2.019 MB/22.26 MB
b165f42e8fd4: Download complete
a24b392c6844: Download complete
#查看下载的镜像
docker images
#运行镜像
docker run -d -p 80:80 180.76.150.184/library/nginx-04-18
#访问测试
curl http://60.1.1.14/