查看images
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
grafana/grafana latest e511606aee56 2 weeks ago 206MB
创建并运行镜像
[root@localhost ~]# docker run -ti --name grafana -d grafana/grafana
8ebbf6ca28c2fbebab7b1a86345cd3097ec253c894ba01c7d1d40bffcc9067b6
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8ebbf6ca28c2 grafana/grafana "/run.sh" 5 seconds ago Up 4 seconds 3000/tcp grafana
进入容器并修改defaults.ini文件
[root@localhost ~]# docker exec -it -u root 8ebbf6ca28c2 /bin/bash
bash-5.1# vi conf/defaults.ini
在配置文件conf/defaults.ini中的[plugins]下添加
allow_loading_unsigned_plugins = alexanderzobnin-zabbix-datasource
若是有多个插件缺少签名用“,”分割
将容器转为镜像
[root@localhost ~]# docker commit 8ebbf6ca28c2 grafana:v8.0.6
语法 :docker commit containerId dockerUserName/RepoName
containerId可以在bash命令行中找到,在root@0ba2492453es:/#中@和:之间的文字即为容器id。
containerId为你需要上传的容器id,dockerUserName为dockerHub的登录名,xxx为仓库名,当然也不一定非得是dockerUserName/xxx,只是为了方便起见
这一步运行后,容器的修改将会被保存为新的镜像,已经可以在本地进行调用了
[root@localhost ~]# docker tag 859e05b33b5b hor.wo.com/infra/grafana:v8.0.6
语法:docker tag imageName dockerUserName/xxx[:tag]
imageName为你需要上传的镜像name,dockerUserName为dockerHub的登录名,xxx为仓库名,必须和你在dockerhub中新建的仓库名相同,tag不指定就是latest
登录到Harbor
[root@localhost ~]# docker login hor.wo.com
Username: admin
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
提交镜像到Docker Hub
[root@localhost ~]# docker push hor.wo.com/infra/grafana:v8.0.6
docker push dockerUserName/xxx[:tag]
#tag不指定就是latest
最后,去Docker Hub上查看是否上传成功,至此,使用docker已经可以使用刚上传的镜像文件啦