grafana docker 安装使用

1.配置yum源

vim /etc/yum.repos.d/docker.repo 添加 
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7 enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg

2.使用yum命令安装docker

 yum install docker

3.启动测试docker

service docker start
service docker status
Redirecting to /bin/systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2017-09-21 16:49:14 CST; 7s ago
     Docs: http://docs.docker.com
 Main PID: 57748 (dockerd-current)
   CGroup: /system.slice/docker.service
           ├─57748 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgr...
           └─57759 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-inte...

Sep 21 16:49:13 yq-hadoop-184201 dockerd-current[57748]: time="2017-09-21T16:49:13.564336376+08:00" level=warning msg="Docker could not enable SELinux on... system"
Sep 21 16:49:13 yq-hadoop-184201 dockerd-current[57748]: time="2017-09-21T16:49:13.718614700+08:00" level=info msg="Graph migration to content-addressabi...seconds"
Sep 21 16:49:13 yq-hadoop-184201 dockerd-current[57748]: time="2017-09-21T16:49:13.719167634+08:00" level=info msg="Loading containers: start."
Sep 21 16:49:13 yq-hadoop-184201 dockerd-current[57748]: time="2017-09-21T16:49:13.786309409+08:00" level=info msg="Firewalld running: false"
Sep 21 16:49:14 yq-hadoop-184201 dockerd-current[57748]: time="2017-09-21T16:49:14.053544531+08:00" level=info msg="Default bridge (docker0) is assigned ...address"
Sep 21 16:49:14 yq-hadoop-184201 dockerd-current[57748]: time="2017-09-21T16:49:14.313472144+08:00" level=info msg="Loading containers: done."
Sep 21 16:49:14 yq-hadoop-184201 dockerd-current[57748]: time="2017-09-21T16:49:14.313593050+08:00" level=info msg="Daemon has completed initialization"
Sep 21 16:49:14 yq-hadoop-184201 dockerd-current[57748]: time="2017-09-21T16:49:14.313615684+08:00" level=info msg="Docker daemon" commit="0fdc778/1.12.6...n=1.12.6
Sep 21 16:49:14 yq-hadoop-184201 dockerd-current[57748]: time="2017-09-21T16:49:14.320056675+08:00" level=info msg="API listen on /var/run/docker.sock"
Sep 21 16:49:14 yq-hadoop-184201 systemd[1]: Started Docker Application Container Engine.

docker run hello-world
测试docker 安装是否有问题
docker version #查看版本

4.下载并运行grafana ,端口映射3000
但是这样启动的容器数据会因为重启而丢失所以官方推荐下面的方式来启动

docker run -d --name=grafana -p 3000:3000 grafana/grafana

另一种方式
创建持久化volume

docker run -d -v /var/lib/grafana --name grafana-storage busybox:latest

从volume获得数据启动

docker run \
  -d \
  -p 3000:3000 \
  --name=grafana \
  --volumes-from grafana-storage \
  grafana/grafana

5.查看镜像

# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
docker.io/grafana/grafana   latest              e4accc9ea909        6 days ago          302.8 MB
docker.io/hello-world       latest              05a3bd381fc2        8 days ago          1.84 kB

6.启动docker

 docker run -d -i -t e4accc9ea909 -p 3000:3000  /bin/bash

7.如果进入docker容器,比较常见的做法有

  1. 使用docker attach
# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                    NAMES
7d0a68fe4562        grafana/grafana     "/run.sh"           22 minutes ago      Up 22 minutes       0.0.0.0:3000->3000/tcp   grafana

docker attach 7d0a68fe4562
  1. 使用SSH
  2. 使用exec
    docker exec -it 7d0a68fe4562 /bin/bash
  3. 使用nsenter
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值