部署Docker web UI应用
下载并运行容器:
# docker pull uifd/ui-for-docker
# docker run -it -d --name docker-web -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock docker.io/uifd/ui-for-docker
浏览器访问测试:
ip:9000
部署私有仓库应用
仓库镜像
Docker hub官方已提供容器镜像registry,用于搭建私有仓库
拉取镜像
[root@docker ~]# docker pull daocloud.io/library/registry:latest
运行容器
[root@docker ~]# docker run --restart=always -d -p 5000:5000 daocloud.io/library/registry
注:如果创建容器不成功,报错防火墙,解决方案如下
# systemctl stop firewalld
# yum install iptables*
# systemctl start iptables
# iptables -F
# systemctl restart docker
[root@docker ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4c1a9e7f73a1 daocloud.io/library/registry "/entrypoint.sh /etc…" 38 seconds ago Up 2 seconds 0.0.0.0:5000->5000/tcp hungry_bouman
连接容器查看端口状态:
[root@docker ~]# docker exec -it if444285deb8 /bin/sh //这里是sh,不是bash
/ # netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 :::5000 :::* LISTEN 1/registry
在本机查看是否访问该私有仓库,看看状态码是不是200
[root@docker ~]# curl -I 192.168.160.15:5000
HTTP/1.1 200 OK
Cache-Control: no-cache
Date: Fri, 07 Aug 2020 13:27:43 GMT
为了方便,下载1个比较小的镜像,busybox
[root@docker ~]# docker pull busybox
上传前必须给镜像打tag,注明ip和端口:
[root@docker ~]# docker tag busybox 本机ip:端口/busybox
这里直接从官方拉的镜像,很慢:
[root@docker ~]# docker tag busybox 192.168.160.15:5000/busybox
下面这个Mysql是我测试的第二个镜像,从daocloud拉取的:
[root@docker ~]# docker tag daocloud.io/library/mysql 192.168.160.15:5000/daocloud.io/library/mysql
注:tag后面可以使用镜像名称也可以使用id,我这里使用的镜像名称,如果使用官方的镜像,不需要加前缀,但是daocloud.io的得加前缀
修改请求方式为http:
默认为https,不改会报以下错误:
Get https://master.up.com:5000/v1/_ping: http: server gave HTTP response to HTTPS
client
# vim /etc/docker/daemon.json
重启docker
[root@docker ~]# systemctl restart docker
上传镜像到私有仓库
[root@docker ~]# docker push 192.168.160.15:5000/busybox
[root@docker ~]# docker push 192.168.160.15:5000/daocloud.io/library/mysql
查看私有仓库里的所有镜像:
—注意我这里是用的ubuntu的例子
# curl 192.168.160.15:5000/v2/_catalog
{"repositories": ["daocloud.io/ubuntu"]}
或者:
# curl http://192.168.160.15:5000/v2/daocloud.io/ubuntu/tags/list
{"name": "daocloud.io/ubuntu", "tags": ["v2"]}
评论区