首页 > 其他分享 >自定义创建Docker镜像,上传至Docker Hub并使用

自定义创建Docker镜像,上传至Docker Hub并使用

时间:2022-11-09 11:00:49浏览次数:43  
标签:ganglia 自定义 Hub Ganglia unspecified gmond 镜像 docker Docker

自定义创建Docker镜像

选择基础镜像系统

首先第一步是需要拉取centos:7作为基础镜像系统,以后所有操作均在此基础之上构建。

docker pull centos:7

确定镜像的功能

确定自己创建镜像应该提供一个怎样的功能,或者说该镜像做一件什么样的事情。

最近刚好需要对Linux服务器系统资源做一定监控,恰好发现Ganglia可以实现,于是决定将其封装成docker镜像使用。

基于选择的基础镜像创建容器

docker run -itd --name ganglia --privileged=true centos:7

Ganglia概述

Ganglia是一个开源大规模集群监控软件,用于测量数以千计的节点,适合分布式集群或并行集群监控。主要是用来监控系统性能,如:cpu 、mem、硬盘利用率,I/O负载、网络流量情况等

官网地址:http://ganglia.info/

核心组成

Ganglia由gmond、gmetad和ganglia-web三部分组成。

gmond(Ganglia Monitoring Daemon)是一种轻量级服务,安装在每台需要收集指标数据的节点主机上。使gmond,可以很容易收集很多系统指标数据,如CPU、内存、磁盘、网络和活跃进程的数据等。

gmetad(Ganglia Meta Daemon)定期检查gmonds,从那里拉取数据,整合所有信息,并将其以RRD格式存储至磁盘的服务。

gweb(Ganglia Web)Ganglia可视化工具,安装在有gmetad运行的机器上,以便读取RRD文件。 gweb是一种利用浏览器显示gmetad所存储数据的PHP前端。在Web界面中以图表方式展现集群的运行状态下收集的多种不同指标数据。

开始构建

进入容器内部进行构建操作

docker exec -it ganglia  /bin/bash

安装httpd服务与php

yum -y install httpd php

安装其他依赖

yum -y install rrdtool perl-rrdtool rrdtool-devel
yum -y install apr-devel

安装ganglia

yum -y install ganglia-gmetad
yum -y install ganglia-web
yum install -y ganglia-gmond

配置

修改配置文件 vim /etc/httpd/conf.d/ganglia.conf

Alias /ganglia /usr/share/ganglia
<Location /ganglia>
  Order deny,allow
  Deny from all
  # Allow from 127.0.0.1
  # Allow from ::1
  # Allow from .example.com
</Location>

Alias /ganglia /usr/share/ganglia
<Location /ganglia>
  # Order deny,allow
  # Deny from all
  # Allow from 127.0.0.1
  # Allow from ::1
  Allow from all
  # Allow from .example.com
  
  Require all granted
</Location>

修改配置文件vim /etc/ganglia/gmetad.conf

data_source "my cluster" localhost(本机的ip地址)

修改配置文件vim /etc/ganglia/gmond.conf

cluster {
  name = "unspecified"
  owner = "unspecified"
  latlong = "unspecified"
  url = "unspecified"
}

cluster {
  name = "my_cluster"
  owner = "unspecified"
  latlong = "unspecified"
  url = "unspecified"
}
udp_send_channel {
  #bind_hostname = yes # Highly recommended, soon to be default.
                       # This option tells gmond to use a source address
                       # that resolves to the machine's hostname.  Without
                       # this, the metrics may appear to come from any
                       # interface and the DNS names associated with
                       # those IPs will be used to create the RRDs.
  mcast_join = 239.2.11.71
  port = 8649
  ttl = 1
}

udp_send_channel {
  #bind_hostname = yes # Highly recommended, soon to be default.
                       # This option tells gmond to use a source address
                       # that resolves to the machine's hostname.  Without
                       # this, the metrics may appear to come from any
                       # interface and the DNS names associated with
                       # those IPs will be used to create the RRDs.
  # mcast_join = 239.2.11.71
  host=127.0.0.1
  port = 8649
  ttl = 1
}
udp_recv_channel {
  mcast_join = 239.2.11.71
  port = 8649
  bind = 239.2.11.71
  retry_bind = true
  # Size of the UDP buffer. If you are handling lots of metrics you really
  # should bump it up to e.g. 10MB or even higher.
  # buffer = 10485760
}


udp_recv_channel {
  # mcast_join = 239.2.11.71
  port = 8649
  bind = 127.0.0.1
  retry_bind = true
  # Size of the UDP buffer. If you are handling lots of metrics you really
  # should bump it up to e.g. 10MB or even higher.
  # buffer = 10485760
}

修改配置文件vim /etc/selinux/config

SELINUX=disabled

启动相关服务

启动服务

systemctl httpd start
systemctl gmetad start
systemctl gmond start

设置开机启动

systemctl enable start
systemctl enable start
systemctl enable start

将容器提交为镜像

基于基础容器之上进行操作完成后,将其提交为新的镜像

docker commit ganglia  ganglia:latest

使用创建的镜像创建容器

docker run -itd --name ganglia -p 8080:80 -p 8081:8649  --privileged=true ganglia:latest

访问:IP:8080/ganglia 在这里插入图片描述

在这里插入图片描述

Docker Hub

注册账号

访问: https://hub.docker.com/注册账号

登录账号

命令行登录账号

docker login -u username

Tag镜像

新建一个tag,名字必须跟注册账号一样

docker tag test:v1 username/test:v1

推送

docker push username/test:v1

拉取

docker pull username/test:v1

部署

docker run -itd 8080:80 username/test:v1

标签:ganglia,自定义,Hub,Ganglia,unspecified,gmond,镜像,docker,Docker
From: https://blog.51cto.com/chencoding/5835180

相关文章

  • 关于Docker的一些事--Docker概述
    为什么会出现docker?背景以一个食品工厂为例子,有一款食品产品,从研发到包装,需要分别两套生产线,虽然感觉说很好,符合SOP,但是吧,产能很慢,这是为什么呢?研发:食品搭配、颜色搭配......
  • Docker安装和常用配置
    Docker安装:Docker安装的一个简单的方式是直接通过官方的安装脚本,指定阿里云镜像可以加快速度。curl-fsSLhttps://get.docker.com|bash-sdocker--mirrorAliyun......
  • 使用github管理iOS分布式项目开发
    使用github管理iOS分布式项目开发 在我们iOS项目开发过程中,我们的团队成员都是分散的、分布式,这个项目管理带来了挑战。Git是一个能够进行版本管理的软件,它是cvs和svn的未......
  • uniapp-uview 微信小程序form中自定义校验规则失效问题。
    uniapp-uview微信小程序form中自定义校验规则失效问题。仔细阅读官方文档,发现有提示。需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。如......
  • Docker 如何实现非root用户构建httpd镜像以及遇到的问题有哪些
    为什么要用非root来构建httpd呢?由于公司云平台,一般的web组件。不允许用root用户来部署相关应用程序。所以只能编写dockerfile先构建镜像,然后再部署到云平台(kubenetes集群),主......
  • k8s--docker状态码
    最常见的退出码,来回答两个重要问题:这些退出码是什么意思?导致该退出码的动作是什么?exitcode:代表一个进程的返回码,通过系统调用exit_group来触发。在POSIX中,0代表正常......
  • 第2-1-5章 docker安装MinIO实现文件存储服务-springboot整合minio-minio全网最全的资
    目录1.MinIO介绍2.MinIO应用场景2.1单主机单硬盘模式2.2单主机多硬盘模式2.3多主机多硬盘分布式3.MinIO特点4.存储机制5.docker安装MinIO6.docker-compose安装Min......
  • valheim英灵神殿Linux使用docker开服
    valheim英灵神殿Linux使用docker开服使用机器:2核4G的Ubuntu,swap设置为8G(满足配置能装docker的Linux就行)在docker官网的镜像站有别人封装好的镜像,我们下载下来启动就可......
  • 【luffy】前台全局样式、后台主页模块接口、跨域问题、自定义配置、git介绍和安装
    目录1.前台全局样式和js配置1.1bodydiv默认样式,统一去掉1.2全局配置2.后台主页模块接口2.1根据原型图分析出来2.2软件开发模式2.3轮播图表2.4轮播图接口编写3.......
  • 码云GitHub Fork代码仓和提交PR代码
    码云/GitHubFork代码仓并提交PR代码背景:在企业开发过程中,都会有自己的代码仓管理,一般会有一个上游代码仓,然后自己fork下该项目,提交到自己下面的项目,并提交PR(或MR)进行合......