harbor

是存放镜像的仓库,公司内部可以使用自己的镜像

docker compose  是在一台机器上进行容器编排的工具  --》导演

    编排: 可以同时启动很多个容器,多个容器之间可以链接

    docker-compose.yml  --》配置文件 定义了如何去启动很多容器,以及容器的参数,例如:镜像,卷,链接,网络等信息

k8s  kubernetes : 是可以在多台机器上进行容器编排的工具 ---》集群容器编排工具

harbor的安装

1.提前条件是安装好docker和docker compose

2.下载harbor的源码

[root@docker compose]# mkdir /harbor

[root@docker compose]# cd /harbor

[root@harbor harbor]# ls

harbor-offline-installer-v2.1.0.tgz

[root@docker harbor]# tar xf harbor-offline-installer-v2.8.3.tgz

[root@docker harbor]# cd harbor

[root@docker harbor]# ls

common.sh  harbor.v2.8.3.tar.gz  harbor.yml.tmpl  install.sh  LICENSE  prepare

[root@docker harbor]# cp harbor.yml.tmpl harbor.yml

[root@harbor harbor]# vim harbor.yml

hostname: 192.168.159.142   #修改

#注释掉了https的配置

#其他的配置没有修改

# https related config

#https:

  # https port for harbor, default is 443

#  port: 443

  # The path of cert and key files for nginx

#  certificate: /your/certificate/path

#  private_key: /your/private/key/path

[root@docker harbor]# ./install.sh   执行安装脚本

✔ ----Harbor has been installed and started successfully.----

[root@docker harbor]# docker compose ps  查看harbor相关容器运行情况

NAME                IMAGE                                COMMAND                                SERVICE       CREATED          STATUS                             PORTS

harbor-core         goharbor/harbor-core:v2.8.3          "/harbor/entrypoint.sh"                core          23 seconds ago   Up 19 seconds (health: starting)  

harbor-db           goharbor/harbor-db:v2.8.3            "/docker-entrypoint.sh  13"            postgresql    23 seconds ago   Up 20 seconds (health: starting)  

harbor-jobservice   goharbor/harbor-jobservice:v2.8.3    "/harbor/entrypoint.sh"                jobservice    23 seconds ago   Up 15 seconds (health: starting)  

在windows机器上访问网站,去配置harbor

http://192.168.159.142/

默认的登录的用户名和密码

admin  Harbor12345

=====

在harbor里创建一个项目sanchuang

并且新建一个用户 feng  密码是Admin@123

授权sanchuang这个项目允许feng这个用户去访问,授予项目管理员权限

===

四、本机上传拉取镜像

在另外一台Ubuntudocker宿主机上使用这个仓库

[root@docker1 ~]# cat /etc/docker/daemon.json

{

  "registry-mirrors": ["https://ruk1gp3w.mirror.aliyuncs.com"],

  "insecure-registries" : ["192.168.159.142:80"]

}

[root@docker1 ~]# systemctl daemon-reload

[root@docker1 ~]# systemctl restart docker

在原来安装harbor的宿主机上,重新启动harbor相关的容器

[root@docker harbor]# cd /harbor/harbor

[root@docker harbor]# docker compose up -d

[+] Running 9/9

 ✔ Container harbor-log  Running                                                                                

 ✔ Container redis    Started                                                                                

 ✔ Container registry   Started                                                                                

 ✔ Container harbor-portal Started                                                                                

 ✔ Container registryctl  Started                                                                                

 ✔ Container harbor-db  Started                                                                                

 ✔ Container harbor-core Started                                                                                

 ✔ Container nginx    Started                                                                                

 ✔ Container harbor-jobservice  Started                                                                                

2、修改镜像的名字

[root@docker docker]# docker tag mysql:1.0 192.168.203.128:80/sanchuang/mysql:1.0

登录使用feng这个用户,密码是Sc123456

[root@docker docker]# docker login  192.168.159.142:80

Username: feng

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

在ubuntu机器上login,然后tag镜像改名,再push到harbor服务器里

添加harbor服务器的地址

root@sc:~/liu# vim /etc/docker/daemon.json

{

  "registry-mirrors": ["https://hub.docker-alhk.dkdun.com/"],

  "insecure-registries" : ["192.168.205.137:80"]

}

root@sc:~/liu# systemctl daemon-reload

root@sc:~/liu# systemctl restart docker

登录

root@sc:~/liu# docker login http://192.168.159.142:80

Username: feng

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/#credential-stores

Login Succeeded

root@sc:~/liu#

root@sc:~/liu# docker tag 2ba278e9c4a1 192.168.205.137:80/sanchuang/myapp:1.0

root@sc:~/liu# docker images

REPOSITORY                                            TAG       IMAGE ID       CREATED             SIZE

liuapp                                                1.0       3d03784b9c0c   About an hour ago   71.7MB

192.168.205.137:80/sanchuang/myapp                    1.0       2ba278e9c4a1   6 hours ago         161MB

myapp                                                 1.0       2ba278e9c4a1   6 hours ago         161MB

registry.ap-southeast-1.aliyuncs.com/califeng/myapp   1.0       2ba278e9c4a1  

root@sc:~/liu# docker push 192.168.205.137:80/sanchuang/myapp:1.0

The push refers to repository [192.168.205.137:80/sanchuang/myapp]

0b1bc1242523: Pushed

4c276e6ec327: Pushed

c630e6bef292: Pushed

46a0d997bbbe: Pushed

7a287aad297b: Pushed

7ea2b60b0a08: Pushed

568944187d93: Pushed

b60e5c3bcef2: Pushed

1.0: digest: sha256:54108f02d38d6fd2f2f7748d7b49ec6d191450fa9f8d1f99fbbbefd282f3a1c2 size: 2003

  • 14
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值