安装 docker-ce
下载 docker-ce.repo:
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
编辑 docker-ce.repo:
- VIM /etc/yum.repos.d/docker-ce.repo
- :%s#download.docker.com#mirrors.tuna.tsinghua.edu.cn/docker-ce#g
- :wq
- yum install docker-ce -y
启动 docker:
systemctl start docker
安装 docker-compose
- wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
- yum install docker-compose -y
安装 harbor
下载安装:
- wget https://storage.googleapis.com/harbor-releases/release-1.9.0/harbor-offline-installer-v1.9.0.tgz
- tar xf harbor-offline-installer-v1.9.0.tgz -C /usr/local
- # 编辑
VIM harbor.YAML
- hostname: 192.168.1.5
- ./install.sh
访问 harbor:
http://192.168.1.5
密码: admin/Harbor12345
在 harbor 文件下因为 docker-compose.YAML 的存在, 所以可以通过 docker-compose 命令来控制 harbor 的启动与关闭, 下面 docker-compose 命令都可以在此文件夹下生效:
- Commands:
- build Build or rebuild services
- bundle Generate a Docker bundle from the Compose file
- config Validate and view the Compose file
- create Create services
- down Stop and remove containers, networks, images, and volumes
- events Receive real time events from containers
- exec Execute a command in a running container
- help Get help on a command
- images List images
- kill Kill containers
- logs View output from containers
- pause Pause services
- port Print the public port for a port binding
- ps List containers
- pull Pull service images
- push Push service images
- restart Restart services
- rm Remove stopped containers
- run Run a one-off command
- scale Set number of containers for a service
- start Start services
- stop Stop services
- top Display the running processes
- unpause Unpause services
- up Create and start containers
- version Show the Docker-Compose version information
比如可以通过 docker-compoe start 来启动 harbor.
向仓库提交镜像
创建用户:
退出用新用户登录之后创建项目:
本地镜像打标记:
- docker pull busybox
- docker tag busybox 192.168.1.5/myproject/mybusybox:v0.1
编辑 / etc/docker/daemon.JSON 添加一行信任规则:
"insecure-registries": ["192.168.1.5"]
登录并推送:
- docker login 192.168.1.5
- docker push 192.168.1.5/myproject
然后在 harbor 上就可以看到我们推送的镜像了:
删除镜像并从 harbor 上拉取:
- docker rmi 192.168.1.5/myproject/mybusybox:v0.1
- docker pull 192.168.1.5/myproject/mybusybox:v0.1
- docker images:
来源: http://www.bubuko.com/infodetail-3210520.html