Docker install for rhel7


RHEL 7 Installation

Prerequisites

  1. Ask sysadmin to get 100G SAN added to the host, and add it as a volume group in lvm. (Mounting is not needed)
  2. Also note that / on rhel 7.2 image is too little, Sysadmin should provision with bigger /.
  3. Go to Docker Installation page for the latest versions of rpm/deb and install process.
  4. For our initial installation we are focusing on RHEL7.1 install which can be found here: https://docs.docker.com/engine/installation/linux/rhel/

Setting up storage for docker

  • Set up thinpool storage for the docker & /data for the local storage. The volume group is named vgsan. The volume for /data is named lvdata. The thin pool is named cr8-thinpool.

    ?
    [root@r system] # lvm
    # scan volume groups
    lvm> vgs
       VG    #PV #LV #SN Attr   VSize   VFree
       vgsan   1   2   0 wz--n- 100.00g 3.00g
      
    # create a 20G /data volume
    lvm> lvcreate -L 20G -n lvdata vgsan
    WARNING: ext4 signature detected on /dev/vgsan/lvdata at offset 1080. Wipe it? [y /n ]: y
       Wiping ext4 signature on /dev/vgsan/lvdata .
       Logical volume "lvdata" created.
      
    # create logical volumes for 75G thinpool & 1G metadata (2 steps)
    lvm> lvcreate --wipesignatures y -L 75G -n cr8-thinpool vgsan
    lvm> lvcreate --wipesignatures y -L 1G -n cr8-thinpoolmeta vgsan
      
    # convert cr8-thinpool in to a pool
    lvm> lvconvert -y --zero n -c 512K --thinpool vgsan /cr8-thinpool --poolmetadata vgsan /cr8-thinpoolmeta
       WARNING: Converting logical volume vgsan /cr8-thinpool and vgsan /cr8-thinpoolmeta to pool's data and metadata volumes.
       THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
       Converted vgsan /cr8-thinpool to thin pool.
      
    # scan logical volumes
    lvm> lvs
       LV           VG    Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
       cr8-thinpool vgsan twi-a-t--- 75.00g             0.00   0.01
       lvdata       vgsan -wi-a----- 20.00g
  • Create ext4 filesystem on /dev/vgsan/lvdata and mount as /data

    ?
    [root lib]# mkfs.ext4 /dev/vgsan/lvdata
    mke2fs 1.42 . 9 ( 28 -Dec- 2013 )
    Writing superblocks and filesystem accounting information: done
     
    [root @r  lib]# mkdir /data
    [root @r  lib]# vim /etc/fstab
    ...
    /dev/vgsan/lvdata   /data             ext4    defaults    1 2
    ...
    [root @r ]# mount /data
  • Now create LVM thinpool profile for & activate the cr8-thinpool 

    ?
    [root@r ~] # vim /etc/lvm/profile/vgsan-cr8-thinpool.profile
    activation {
         thin_pool_autoextend_threshold=80
         thin_pool_autoextend_percent=20
    }
     
    [root@rtp -wadl -dsbld /] # lvchange --metadataprofile vgsan-cr8-thinpool vgsan/cr8-thinpool
       Logical volume "cr8-thinpool" changed.

     Install docker using yum

  1. Log into your machine as a user with sudo or root privileges.

  2. Enable updates with yum.

    ?
    yum-config-manager --enable "*pdates"


  3. Add the docker yum repo yourself.

    ?
    echo "[dockerrepo]
    name=Docker Repository
    baseurl=https: //yum.dockerproject.org/repo/main/centos/7
    enabled= 1
    gpgcheck= 1
    gpgkey=https: //yum.dockerproject.org/gpg" > /etc/yum.repos.d/docker.repo
  4. Install the Docker package and disable updates

    ?
    yum install docker-engine
    yum-config-manager --disable "*pdates"

  5. Before starting docker, configure it to use the thinpool storage. Add these lines to /etc/docker/daemon.json. The dm.thinpool device is /dev/mapper/vgsan-cr8--thinpool (device mapper escapes - with --)

    ?
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    {    "storage-driver" : "devicemapper" ,
         "storage-opts" : [
             "dm.thinpooldev=/dev/mapper/vgsan-cr8--thinpool" ,
             "dm.use_deferred_removal=true"
         ],
         "cluster-store" : "" ,
         "cluster-store-opts" : {},
         "cluster-advertise" : "" ,
         "max-concurrent-downloads" : 3,
         "max-concurrent-uploads" : 5,
         "debug" : false ,
         "hosts" : [
             "unix:///var/run/docker.sock" ,
             "tcp://127.0.0.1:2376"
         ],
         "group" : "docker-squad-devops" ,
         "ip" : "0.0.0.0" ,
         "bip" : "10.0.16.1/20" ,
         "fixed-cidr" : "10.0.16.0/20"
    }
  6. Enable docker daemon & start the service

    Expected output
    ?
    [root @ /]# systemctl enable docker
    Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
     
    [root @rt  /]# systemctl daemon-reload
      
    [root @rt /]# systemctl start docker
      
    [root @rt  ~]# systemctl status docker
    ● docker.service - Docker Application Container Engine
        Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
        Active: active (running) since Thu 2016 - 09 - 08 20 : 39 : 41 GMT; 6s ago
          Docs: https: //docs.docker.com
      Main PID: 17086 (dockerd)
        Memory: 15 .9M
        CGroup: /system.slice/docker.service
                ├─ 17086 /usr/bin/dockerd
                └─ 17092 docker-containerd -l unix: ///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --runtime docker-runc
     
  7. Inspect docker info to ensure correct storage driver is being used

    ?
    [root @r ~]# docker info | grep -i pool
      Pool Name: vgsan-cr8--thinpool
      Pool Blocksize: 524.3 kB
      Thin Pool Minimum Free Space: 8.053 GB

    Troubleshooting installs on RHEL.

  1. Stopping all containers & remove all images

    ?
    docker kill $(docker ps -q)
    docker rm $(docker ps -a -q)
    docker rmi $(docker images -q)
  2. Unistall rpms

    ?
    [root @rt /]# yum remove -y docker-engine
      
    # check if docker rpms
    [root @r /]# rpm -qa | grep docker



  3. On Centos/RHEL docker uses device mapper based sparse file, these are basically all loop mounted (clean them). You can inspect all block devices using lsblk. The devicemapper ones can be removed using dmsetup

    ?
    [root @r /]# lsblk
    NAME                                                                                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    fd0                                                                                         2 : 0    1    4K  0 disk
    sda                                                                                         8 : 0    0   10G  0 disk
    └─sda1                                                                                      8 : 1    0   10G  0 part /
    sdb                                                                                         8 : 16   0  100G  0 disk
    └─vgsan-lvdata                                                                            253 : 0    0  100G  0 lvm
    sr0                                                                                        11 : 0    1 1024M  0 rom
    loop0                                                                                       7 : 0    0  100G  0 loop
    └─docker- 253 : 0 - 2490381 -pool                                                               253 : 1    0  100G  0 dm
       └─docker- 253 : 0 - 2490381 -0f32d2483af9599e707e6aedcf46dab133a976005a81a20706d81980fc32dec2 253 : 3    0   10G  0 dm
    activation {
    loop1                                                                                       7 : 1    0    2G  0 loop
    └─docker- 253 : 0 - 2490381 -pool                                                               253 : 1    0  100G  0 dm
       └─docker- 253 : 0 - 2490381 -0f32d2483af9599e707e6aedcf46dab133a976005a81a20706d81980fc32dec2 253 : 3    0   10G  0 dm
      
    # umount & delete em
    [root @ /]# for dm in /dev/mapper/docker-*; do umount $dm; dmsetup remove $dm; done
    umount: /dev/mapper/docker- 253 : 0 - 2490381 -0f32d2483af9599e707e6aedcf46dab133a976005a81a20706d81980fc32dec2: not mounted
    umount: /dev/mapper/docker- 253 : 0 - 2490381 -pool: not mounted
  4. Docker startup using systemd. Check that you are not passing any commandline args. Since we are using daemon.json now.

    ?
    [root @ /]# vim /usr/lib/systemd/system/docker.service
    [root /]# ls -l /etc/systemd/system/docker.service.d/*

    Ubuntu Installation

Up to date installation instructions can be found on the Docker website here: https://docs.docker.com/engine/installation/linux/ubuntulinux/

This installation method worked for Ubuntu Trusty 14.04

  1. Login with sudo and root access to the Ubuntu installation target.
  2. Verify the version of Ubuntu that you're installing on and also ensure the kernel version is at least 3.10+

    ?
    # Check version of ubuntu
    lsb_release -a
     
    # Check kernel version
    uname -r
  3. Edit the /etc/apt/sources.list.d/docker.list and add the correct information for the version of Ubuntu you're installing on and add the following respective entries to that file
    1. On Ubuntu Precise 12.04 (LTS)

      deb https://apt.dockerproject.org/repo ubuntu-precise main
      
    2. On Ubuntu Trusty 14.04 (LTS)

      deb https://apt.dockerproject.org/repo ubuntu-trusty main
      
    3. Ubuntu Wily 15.10

      deb https://apt.dockerproject.org/repo ubuntu-wily main
      

       

  4. Run another update after adding the above package repositories

    ?
    apt-get update
  5. Install docker

    ?
    apt-get install docker-engine
  6. Ensure docker daemon is started

    ?
    service docker start
  7. Verify docker is started correctly by running the hello world container

    ?
    docker run hello-world

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值