zoukankan      html  css  js  c++  java
  • 【原创】Redhat安装部署docker

    1 在 CentOS 6.4 上安装 docker

    docker当前官方只支持Ubuntu,所以在 CentOS 安装Docker比较麻烦(Issue #172)。

    docker官方文档说要求Linux kernel至少3.8以上,CentOS 6.4是2.6的内核,于是我哼哧哼哧的编译安装了最新的kernel 3.11.6,重启后运行docker还是失败,最后找到原因,是因为编译时忘记集成aufs模块了。aufs 需要和 kernel 一起编译,很麻烦。

    不过不需要这么麻烦,有强人已经编译好了带aufs模块的内核,见这里Installing docker.io on centos 6.4 (64-bit)

    1.1 取消selinux,因为它会干扰lxc的正常功能

    sudo vim /etc/selinux/config 
    SELINUX=disabled
    SELINUXTYPE=targeted
    

    1.2 安装 Fedora EPEL

    sudo yum install http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
    

    1.3 添加 hop5 repo地址

    cd /etc/yum.repos.d
    sudo wget http://www.hop5.in/yum/el6/hop5.repo
    

    1.4 安装 docker-io

    sudo yum install docker-io
    

    会自动安装带aufs模块的3.10内核,以及docker-io包。

    1.5 将 cgroup 文件系统添加到 /etc/fstab , 只有这样docker才能正常工作

    sudo echo "none /sys/fs/cgroup cgroup  defaults 0 0" >> /etc/fstab
    

    1.6 修改grub引导顺序

    sudo vim /etc/grub.conf
    default=0
    

    设置default为新安装的内核的位置,一般是0

    1.7 重启

    sudo reboot
    

    1.8 检查新内核是否引导成功

    重启后,检查一下新内核是否引导起来了

    uname -r
    3.10.5-3.el6.x86_64
    

    说明成功了

    看一下 aufs是否存在

    grep aufs /proc/filesystems 
    nodev   aufs
    

    说明存在

    1.9 启动 docker daemon 进程

    sudo docker -d &
    

    如果你在公司,且公司内部都是通过代理上网,则可以把代理服务器告诉docker,用如下命令(参考这里):

    sudo HTTP_PROXY=http://xxx:port docker -d &
    

    1.10 下载 ubuntu 镜像

    sudo docker pull ubuntu
    

    1.11 运行 hello world

    sudo docker run ubuntu /bin/echo hello world
    hello world
    

    安装成功了!!

    注意如果镜像不可用

    设置docker镜像源

    yum install -y yum-priorities && rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6


    检查hello时

    WARNING IPv4 forwarding is disabled. Networking will not work

    解决办法:
    # vi /etc/sysctl.conf
    或者
    # vi /usr/lib/sysctl.d/00-system.conf
    添加如下代码:
        net.ipv4.ip_forward=1
     
    重启network服务
    # /etc/init.d/network restart
     
    查看是否修改成功
    # sysctl net.ipv4.ip_forward
     
    如果返回为“net.ipv4.ip_forward = 1”则表示成功了
    
    
    
     
  • 相关阅读:
    Linux修改主机名称
    Druid监控SQL语句
    CentOS7.5搭建Hadoop分布式集群
    CentOS7.5 解决ifconfig报错
    windows 用VMware创建linux虚拟机,安装操作系统CentOS7.2
    MySQL报错this is incompatible with sql_mode=only_full_group_by
    CentOS配置Redis环境变量
    CentOS7.4搭建GitLab
    修改服务器路由策略
    Centos7 安装python3
  • 原文地址:https://www.cnblogs.com/maple42/p/5868846.html
Copyright © 2011-2022 走看看