• docker介绍


    简介:docker是目前最火的技术,没有之一

    1,与openstack相比,docker的优点:

    2,docker的使用场景(docker能干什么):

    1,简化配置

    2,提高开发效率

    3,应用隔离

    4,服务器整合

    5,多用户使用

    6,快速部署

    7,代码流水线管理

    8,开发调试

    安装前准备

    升级内核-3.0
    参考文档:http://www.centoscn.com/image-text/install/2014/1128/4202.html
    
    [root@yz6205 soft]# cd /etc/yum.repos.d/
    [root@yz6205 yum.repos.d]# 
    [root@yz6205 yum.repos.d]# ls
    epel.repo  saltstack.repo
    [root@yz6205 yum.repos.d]# wget http://www.hop5.in/yum/el6/hop5.repo .
    --2016-05-29 14:49:07--  http://www.hop5.in/yum/el6/hop5.repo
    Resolving www.hop5.in... 37.139.17.90
    Connecting to www.hop5.in|37.139.17.90|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 138 [text/plain]
    Saving to: “hop5.repo”
    
    100%[===============================================================================>] 138         --.-K/s   in 0s      
    
    2016-05-29 14:49:08 (12.8 MB/s) - “hop5.repo” saved [138/138]
    
    --2016-05-29 14:49:08--  http://./
    Resolving .... failed: No address associated with hostname.
    wget: unable to resolve host address “.”
    FINISHED --2016-05-29 14:49:08--
    Downloaded: 1 files, 138 in 0s (12.8 MB/s)
    [root@yz6205 yum.repos.d]# ls
    epel.repo  hop5.repo  saltstack.repo
    [root@yz6205 yum.repos.d]# more hop5.repo 
    [hop5]
    name=www.hop5.in Centos Repository
    baseurl=http://www.hop5.in/yum/el6/
    gpgcheck=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-HOP5
    [root@yz6205 yum.repos.d]# yum install kernel-ml-aufs kernel-ml-aufs-devel
    [root@yz6205 ~]# cat /etc/grub.conf 
    # grub.conf generated by anaconda
    #
    # Note that you do not have to rerun grub after making changes to this file
    # NOTICE:  You do not have a /boot partition.  This means that
    #          all kernel and initrd paths are relative to /, eg.
    #          root (hd0,0)
    #          kernel /boot/vmlinuz-version ro root=/dev/sda1
    #          initrd /boot/initrd-[generic-]version.img
    #boot=/dev/sda
    #default=1
    default=0
    timeout=5
    splashimage=(hd0,0)/boot/grub/splash.xpm.gz
    hiddenmenu
    title CentOS (3.10.5-3.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-3.10.5-3.el6.x86_64 ro root=UUID=6ed89e91-53be-4216-a435-75739237a105 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=256M  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
        initrd /boot/initramfs-3.10.5-3.el6.x86_64.img
    title CentOS (2.6.32-220.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-220.el6.x86_64 ro root=UUID=6ed89e91-53be-4216-a435-75739237a105 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=256M  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
        initrd /boot/initramfs-2.6.32-220.el6.x86_64.img
    
    重启主机后查看,偶了
    [yongsan@yz6205 ~]$ uname -r
    3.10.5-3.el6.x86_64

    yum报错:

    [yongsan@yz3110 yum.repos.d]$ yum list
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Determining fastest mirrors
    Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
    

      解决:

    vim /etc/yum.repos.d/epel.repo
    #把基础的恢复(baseurl),镜像的地址注释掉(mirrorlist)
    
    [epel]
    name=Extra Packages for Enterprise Linux 6 - $basearch
    baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
    #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
    failovermethod=priority
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
    

    makecache:

     1 Loaded plugins: fastestmirror, refresh-packagekit, security
     2 Loading mirror speeds from cached hostfile
     3  * base-vault: pub.repos.sina.cn
     4  * extras-vault: pub.repos.sina.cn
     5  * sina: pub.repos.sina.cn
     6  * sina-updates: pub.repos.sina.cn
     7  * updates-vault: pub.repos.sina.cn
     8 base-vault                                                                                                                                      | 3.7 kB     00:00     
     9 base-vault/group_gz                                                                                                                             | 220 kB     00:00     
    10 base-vault/filelists_db                                                                                                                         | 5.9 MB     00:00     
    11 base-vault/other_db                                                                                                                             | 2.8 MB     00:00     
    12 epel                                                                                                                                            | 4.3 kB     00:00     
    13 http://download.fedoraproject.org/pub/epel/6/x86_64/repodata/4f6cd9c63b9b1c69b14ca58e826c6bedf320735a7f2f0182e039f1dd68b85812-comps-el6.xml.bz2: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirrors.hustunique.com'"
    14 Trying other mirror.
    15 extras-vault                                                                                                                                    | 3.3 kB     00:00     
    16 extras-vault/filelists_db                                                                                                                       |  11 kB     00:00     
    17 extras-vault/prestodelta                                                                                                                        |  904 B     00:00     
    18 extras-vault/other_db                                                                                                                           |  22 kB     00:00     
    19 sina                                                                                                                                            | 3.6 kB     00:00     
    20 sina/group_gz                                                                                                                                   |  490 B     00:00     
    21 sina/filelists_db                                                                                                                               | 457 kB     00:00     
    22 sina/other_db                                                                                                                                   |  14 kB     00:00     
    23 sina-updates                                                                                                                                    | 2.9 kB     00:00     
    24 sina-updates/filelists_db                                                                                                                       | 133 kB     00:00     
    25 sina-updates/other_db                                                                                                                           |  22 kB     00:00     
    26 updates-vault                                                                                                                                   | 3.4 kB     00:00     
    27 updates-vault/filelists_db                                                                                                                      | 3.0 MB     00:00     
    28 updates-vault/prestodelta                                                                                                                       | 535 kB     00:00     
    29 updates-vault/other_db                                                                                                                          |  46 MB     00:01     
    30 epel/primary_db                                                                                                                                 | 5.8 MB     00:07     
    31 epel/filelists_db                                                                                                                               | 8.0 MB     00:02     
    32 epel/other_db                                                                                                                                   | 2.9 MB     00:01     
    33 Metadata Cache Created
    View Code

    docker安装:

     1 [yongsan@yz3110 yum.repos.d]$ sudo yum -y install docker-io
     2 Loaded plugins: fastestmirror, refresh-packagekit, security
     3 Loading mirror speeds from cached hostfile
     4  * base-vault: pub.repos.sina.cn
     5  * extras-vault: pub.repos.sina.cn
     6  * sina: pub.repos.sina.cn
     7  * sina-updates: pub.repos.sina.cn
     8  * updates-vault: pub.repos.sina.cn
     9 Setting up Install Process
    10 Resolving Dependencies
    11 --> Running transaction check
    12 ---> Package docker-io.x86_64 0:1.7.1-2.el6 will be installed
    13 --> Processing Dependency: lxc for package: docker-io-1.7.1-2.el6.x86_64
    14 --> Running transaction check
    15 ---> Package lxc.x86_64 0:1.0.8-1.el6 will be installed
    16 --> Processing Dependency: lua-lxc(x86-64) = 1.0.8-1.el6 for package: lxc-1.0.8-1.el6.x86_64
    17 --> Processing Dependency: lua-alt-getopt for package: lxc-1.0.8-1.el6.x86_64
    18 --> Processing Dependency: liblxc.so.1()(64bit) for package: lxc-1.0.8-1.el6.x86_64
    19 --> Running transaction check
    20 ---> Package lua-alt-getopt.noarch 0:0.7.0-1.el6 will be installed
    21 ---> Package lua-lxc.x86_64 0:1.0.8-1.el6 will be installed
    22 --> Processing Dependency: lua-filesystem for package: lua-lxc-1.0.8-1.el6.x86_64
    23 ---> Package lxc-libs.x86_64 0:1.0.8-1.el6 will be installed
    24 --> Running transaction check
    25 ---> Package lua-filesystem.x86_64 0:1.4.2-1.el6 will be installed
    26 --> Finished Dependency Resolution
    27 
    28 Dependencies Resolved
    29 
    30 =======================================================================================================================================================================
    31  Package                                      Arch                                 Version                                    Repository                          Size
    32 =======================================================================================================================================================================
    33 Installing:
    34  docker-io                                    x86_64                               1.7.1-2.el6                                epel                               4.6 M
    35 Installing for dependencies:
    36  lua-alt-getopt                               noarch                               0.7.0-1.el6                                epel                               6.9 k
    37  lua-filesystem                               x86_64                               1.4.2-1.el6                                epel                                24 k
    38  lua-lxc                                      x86_64                               1.0.8-1.el6                                epel                                16 k
    39  lxc                                          x86_64                               1.0.8-1.el6                                epel                               122 k
    40  lxc-libs                                     x86_64                               1.0.8-1.el6                                epel                               255 k
    41 
    42 Transaction Summary
    43 =======================================================================================================================================================================
    44 Install       6 Package(s)
    45 
    46 Total download size: 5.0 M
    47 Installed size: 20 M
    48 Downloading Packages:
    49 (1/6): docker-io-1.7.1-2.el6.x86_64.rpm                                                                                                         | 4.6 MB     00:01     
    50 (2/6): lua-alt-getopt-0.7.0-1.el6.noarch.rpm                                                                                                    | 6.9 kB     00:00     
    51 (3/6): lua-filesystem-1.4.2-1.el6.x86_64.rpm                                                                                                    |  24 kB     00:00     
    52 (4/6): lua-lxc-1.0.8-1.el6.x86_64.rpm                                                                                                           |  16 kB     00:00     
    53 (5/6): lxc-1.0.8-1.el6.x86_64.rpm                                                                                                               | 122 kB     00:00     
    54 (6/6): lxc-libs-1.0.8-1.el6.x86_64.rpm                                                                                                          | 255 kB     00:00     
    55 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    56 Total                                                                                                                                  152 kB/s | 5.0 MB     00:33     
    57 warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
    58 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
    59 Importing GPG key 0x0608B895:
    60  Userid : EPEL (6) <epel@fedoraproject.org>
    61  Package: epel-release-6-8.noarch (installed)
    62  From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
    63 Running rpm_check_debug
    64 Running Transaction Test
    65 Transaction Test Succeeded
    66 Running Transaction
    67 Warning: RPMDB altered outside of yum.
    68   Installing : lxc-libs-1.0.8-1.el6.x86_64                                                                                                                         1/6 
    69   Installing : lua-filesystem-1.4.2-1.el6.x86_64                                                                                                                   2/6 
    70   Installing : lua-lxc-1.0.8-1.el6.x86_64                                                                                                                          3/6 
    71   Installing : lua-alt-getopt-0.7.0-1.el6.noarch                                                                                                                   4/6 
    72   Installing : lxc-1.0.8-1.el6.x86_64                                                                                                                              5/6 
    73   Installing : docker-io-1.7.1-2.el6.x86_64                                                                                                                        6/6 
    74 
    75 Installed:
    76   docker-io.x86_64 0:1.7.1-2.el6                                                                                                                                       
    77 
    78 Dependency Installed:
    79   lua-alt-getopt.noarch 0:0.7.0-1.el6   lua-filesystem.x86_64 0:1.4.2-1.el6   lua-lxc.x86_64 0:1.0.8-1.el6   lxc.x86_64 0:1.0.8-1.el6   lxc-libs.x86_64 0:1.0.8-1.el6  
    80 
    81 Complete!
    View Code

    启动:

    [root@yz3110 ~]# /etc/init.d/docker start
    Starting docker: [ OK ]
    [root@yz3110 ~]# docker -d
    WARN[0000] You are running linux kernel version 2.6.32-220.el6.x86_64, which might be unstable running docker. Please upgrade your kernel to 3.10.0.
    INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)
    docker: relocation error: docker: symbol dm_task_get_info_with_deferred_remove, version Base not defined in file libdevmapper.so.1.02 with link time reference

    [root@yz3110 ~]# /etc/init.d/docker status
    docker dead but pid file exists

    [root@yz3110 ~]# rm -f /var/run/docker.pid
    [root@yz3110 ~]# /etc/init.d/docker restart
    Stopping docker: [FAILED]
    Starting docker: [ OK ]

    之后还是提示更新内核

    解决办法:

    执行:yum upgrade device-mapper-libs

    [yongsan@yz6245 yum.repos.d]$ sudo docker -d
    WARN[0000] You are running linux kernel version 2.6.32-220.el6.x86_64, which might be unstable running docker. Please upgrade your kernel to 3.10.0.
    INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)
    ERRO[0000] [graphdriver] prior storage driver "devicemapper" failed: Error running DeviceCreate (CreatePool) dm_task_run failed
    FATA[0000] Error starting daemon: error initializing graphdriver: Error running DeviceCreate (CreatePool) dm_task_run failed

    出现上述错误有如下解决办法!
    *1. yum upgrade device-mapper-libs 再次启动看是否可以
    2. 使用另一种文件系统试一下如:docker -d -s vfs 默认是devicemapper系统 还可以使用aufs
    [root@yz6245 ~]# docker -d
    WARN[0000] You are running linux kernel version 2.6.32-220.el6.x86_64, which might be unstable running docker. Please upgrade your kernel to 3.10.0.
    INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)
    ERRO[0000] [graphdriver] prior storage driver "devicemapper" failed: Error running DeviceCreate (CreatePool) dm_task_run failed
    FATA[0000] Error starting daemon: error initializing graphdriver: Error running DeviceCreate (CreatePool) dm_task_run failed
    [root@yz6245 ~]# docker -d -s vfs
    WARN[0000] You are running linux kernel version 2.6.32-220.el6.x86_64, which might be unstable running docker. Please upgrade your kernel to 3.10.0.
    INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)
    WARN[0000] Running modprobe bridge nf_nat failed with message: , error: exit status 1
    WARN[0000] Your kernel does not support oom control.
    INFO[0000] Loading containers: start.

    INFO[0000] Loading containers: done.
    INFO[0000] Daemon has completed initialization

    [root@yz6245 ~]# /etc/init.d/docker status
    docker (pid 11769) is running...

    欧克了,正常启动了,哈哈

    [root@yz6245 ~]# docker search centos
    NAME                            DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
    centos                          The official build of CentOS.                   1979      [OK]       
    jdeathe/centos-ssh              CentOS-6 6.7 x86_64 / CentOS-7 7.2.1511 x8...   15                   [OK]
    jdeathe/centos-ssh-apache-php   CentOS-6 6.7 x86_64 / Apache / PHP / PHP M...   13                   [OK]
    million12/centos-supervisor     Base CentOS-7 with supervisord launcher, h...   9                    [OK]
    blalor/centos                   Bare-bones base CentOS 6.5 image                8                    [OK]
    nimmis/java-centos              This is docker images of CentOS 7 with dif...   7                    [OK]
    torusware/speedus-centos        Always updated official CentOS docker imag...   7                    [OK]
    nickistre/centos-lamp           LAMP on centos setup                            3                    [OK]
    nathonfowlie/centos-jre         Latest CentOS image with the JRE pre-insta...   3                    [OK]
    centos/mariadb55-centos7                                                        3                    [OK]
    softvisio/centos                Centos                                          1                    [OK]
    timhughes/centos                Centos with systemd installed and running       1                    [OK]
    pacur/centos-7                  Pacur CentOS 7                                  1                    [OK]
    pacur/centos-6                  Pacur CentOS 6                                  1                    [OK]
    lighthopper/orientdb-centos     A Dockerfile for creating an OrientDB imag...   1                    [OK]
    yajo/centos-epel                CentOS with EPEL and fully updated              1                    [OK]
    darksheer/centos                Base Centos Image -- Updated hourly             1                    [OK]
    lighthopper/openjdk-centos      A Dockerfile for creating an OpenJDK image...   0                    [OK]
    blacklabelops/centos            CentOS Base Image! Built and Updates Daily!     0                    [OK]
    ustclug/centos                   USTC centos                                    0                    [OK]
    januswel/centos                 yum update-ed CentOS image                      0                    [OK]
    grayzone/centos                 auto build for centos.                          0                    [OK]
    jsmigel/centos-epel             Docker base image of CentOS w/ EPEL installed   0                    [OK]
    ericuni/centos                  centos dev                                      0                    [OK]
    grossws/centos                  CentOS 6 and 7 base images with gosu and l...   0                    [OK]

    下载镜像:

    [root@yz6245 ~]# docker pull centos
    Pulling repository centos

    查看镜像:

    [root@yz6245 ~]# docker images
    REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
    centos latest bb3d629a7cbc 24 hours ago 196.6 MB
    hello-world latest 975b84d108f1 4 months ago 960 B

    centos6下安装docker
    [root@yz6205 ~]# yum -y install http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarch.rpm
    [root@yz6205 ~]# rpm -qa |grep epel-release
    epel-release-6-8.noarch
    [root@yz6205 ~]# yum -y install docker-io
    [root@yz6205 ~]# docker -d -s vfs
    [root@yz6205 ~]# /etc/init.d/docker status
    docker (pid 22152) is running...

    下载镜像
    [root@yz6205 soft]# docker pull centos
    latest: Pulling from centos
    47d44cb6f252: Pull complete
    5b7145e6c091: Pull complete
    f9bbfacad34f: Pull complete
    db0f5936b391: Pull complete
    Digest: sha256:039c32c0924e4f5da9c4952a86929fe00e10c9473c3948335ff13d00550993dd
    Status: Downloaded newer image for centos:latest

    查看镜像信息
    [root@yz6205 soft]# docker images
    REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
    centos latest db0f5936b391 11 days ago 196.7 MB

    下载特定版本:
    [root@yz6205 soft]# docker pull ubuntu:14.04
    14.04: Pulling from ubuntu
    c570b023c8f9: Downloading [=====> ] 7.56 MB/65.7 MB
    2eba1575ab91: Download complete
    80501fbd0654: Download complete
    f9cdf71c33f1: Download complete
    0e7d4a488bcc: Download complete
    0e7d4a488bcc: Pulling fs layer

    [root@yz6205 soft]# docker pull ubuntu:14.04
    14.04: Pulling from ubuntu
    c570b023c8f9: Pull complete
    2eba1575ab91: Pull complete
    80501fbd0654: Pull complete
    f9cdf71c33f1: Pull complete
    0e7d4a488bcc: Pull complete
    Digest: sha256:7c151496aefa83d7d5faeff87493d471f86ff5673b829b0e1724e66be69d011c
    Status: Downloaded newer image for ubuntu:14.04

    下载镜像到本地后可随时查看使用该镜像了
    [root@yz6205 soft]# docker images
    REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
    ubuntu 14.04 0e7d4a488bcc 39 hours ago 187.9 MB
    centos latest db0f5936b391 11 days ago 196.7 MB
    [root@yz6205 soft]# docker run -t -i ubuntu /bin/bash


    搜寻镜像
    [root@yz6205 soft]# docker search centos
    NAME DESCRIPTION STARS OFFICIAL AUTOMATED
    centos The official build of CentOS. 2290 [OK]
    jdeathe/centos-ssh CentOS-6 6.7 x86_64 / CentOS-7 7.2.1511 x8... 23 [OK]
    jdeathe/centos-ssh-apache-php CentOS-6 6.7 x86_64 / Apache / PHP / PHP M... 17 [OK]
    nimmis/java-centos This is docker images of CentOS 7 with dif... 11 [OK]
    million12/centos-supervisor Base CentOS-7 with supervisord launcher, h... 11 [OK]
    consol/centos-xfce-vnc Centos container with "headless" VNC sessi... 8 [OK]
    torusware/speedus-centos Always updated official CentOS docker imag... 8 [OK]
    nickistre/centos-lamp LAMP on centos setup 4 [OK]
    centos/mariadb55-centos7 3 [OK]
    nathonfowlie/centos-jre Latest CentOS image with the JRE pre-insta... 3 [OK]
    consol/sakuli-centos-xfce Sakuli end-2-end testing and monitoring co... 2 [OK]
    timhughes/centos Centos with systemd installed and running 1 [OK]
    lighthopper/orientdb-centos A Dockerfile for creating an OrientDB imag... 1 [OK]
    yajo/centos-epel CentOS with EPEL and fully updated 1 [OK]
    blacklabelops/centos CentOS Base Image! Built and Updates Daily! 1 [OK]
    darksheer/centos Base Centos Image -- Updated hourly 1 [OK]
    jsmigel/centos-epel Docker base image of CentOS w/ EPEL installed 0 [OK]
    kz8s/centos Official CentOS plus epel-release 0 [OK]
    lighthopper/openjdk-centos A Dockerfile for creating an OpenJDK image... 0 [OK]
    januswel/centos yum update-ed CentOS image 0 [OK]
    ustclug/centos USTC centos 0 [OK]
    ericuni/centos centos dev 0 [OK]
    grayzone/centos auto build for centos. 0 [OK]
    repositoryjp/centos Docker Image for CentOS. 0 [OK]
    grossws/centos CentOS 6 and 7 base images with gosu and l... 0 [OK]

  • 相关阅读:
    Django入门
    初识json
    回来了
    python学习
    JavaScript 中获取元素样式
    浏览器检测与特征检测
    DOM 节点的类型及判定
    浏览器的控制台工具
    .htaccess 配置文件的使用
    workLog:07001:补充0829 前
  • 原文地址:https://www.cnblogs.com/liyongsan/p/5242363.html
Copyright © 2020-2023  润新知