美文网首页k8s
Centos 安装 Docker 环境

Centos 安装 Docker 环境

作者: 木木111314 | 来源:发表于2021-01-21 15:30 被阅读0次

    环境准备

    检查系统环境

    [root@localhost ~]# uname -r
    3.10.0-1062.el7.x86_64
    

    关闭防火墙

    [root@localhost ~]# systemctl stop firewalld
    [root@localhost ~]# systemctl disable firewalld
    Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
    Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
    

    设置yum镜像源

    添加镜像源

    # base repo
    cd /etc/yum.repos.d
    mv CentOS-Base.repo CentOS-Base.repo.bak
    curl -o CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/CentOS-Base.repo
    
    # docker repo
    curl -o docker-ce.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    

    https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b11JC64Pb
    https://developer.aliyun.com/mirror/docker-ce?spm=a2c6h.13651102.0.0.3e221b11UHOUDR

    更新缓存

    yum clean all  
    yum makecache  
    yum repolist
    

    安装 Docker

    安装

    yum install docker-ce-18.06.3.ce
    

    启动

    systemctl enable docker --now
    

    查看docker状态

    systemctl status docker
    

    运行nginx镜像测试docker环境

    docker run  -p 8080:80   --name nginx nginx 
    
    image.png

    如果想让容器后台运行 添加参数 -d ,如果想让容器开机运行 添加参数 --restart=always

    docker run  -p 8080:80  -d  --restart=always   --name nginx nginx 
    

    相关文章

      网友评论

        本文标题:Centos 安装 Docker 环境

        本文链接:https://www.haomeiwen.com/subject/xorrzktx.html