zoukankan      html  css  js  c++  java
  • centos7安装docker

    1、查看linux发行版,内核

    [root@docker~]# cat /etc/redhat-release  #查看版本号
    
    CentOS Linux release 7.1.1503 (Core)
    
    [root@docker ~]# uname -r  #查看Linux内核
    
    c3.10.0-229.el7.x86_64

    2、替换阿里云yum源

    1 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo #下载阿里yum源2 
    
    2 yum makecache  #生成仓库缓存 

    3、安装docker

    yum install docker -y

    4、启动docker

    systemctl start docker  #启动docker
    systemctl enable docker #开机启动docker
    systemctl status docker #查看docker状态

    5、查看docker 版本

    docker version

    #yum装的是1.12.6

    6、DaoCloud 加速器 是广受欢迎的 Docker 工具,解决了国内用户访问 Docker Hub 缓慢的问题。DaoCloud 加速器结合国内的 CDN 服务与协议层优化,成倍的提升了下载速度。

    使用前请先确保您的 Docker 版本在 1.8 或更高版本,否则无法使用加速。

    http://guide.daocloud.io/dcs/daocloud-9153151.html 教程官网

     cat /etc/docker/daemon.json #修改这个文件为如下内容
    
    {
        "registry-mirrors": [
            "http://95822026.m.daocloud.io"
        ],
        "insecure-registries": []
    }
    ---------------------------------------------------------
    或者用这条命令
    curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://95822026.m.daocloud.io
    #事后重启docker
    systemctl restart docker

    7、比如我们要装一个nginx,先搜寻一下有哪些公有镜像,然后开始安装 启动..

    docker search nginx #就找第一个,下载最多的,官方镜像
    docker pull nginx #下载nginx镜像
    docker images #查看有哪些镜像

    8、启动nginx镜像

    docker run -p 8000:80 --name mynginx -d nginx   
    #-p指定服务器8000端口,映射容器80 web端口,容器名为mynginx -d 守护进程模式启动(因为容器必须有进程在运行,否则结束就挂)
    docker ps #查看目前工作的容器
    docker ps -a #查看所有运行过的容器

    9、此时可以用服务器ip地址,在浏览器访问,默认80端口不用写,即可访问到 welcome nginx

    10、可用exec命令进入容器系统

    docker exec -it 容器ID /bin/bash
  • 相关阅读:
    访客登录方案设计与应用
    VS Code下载
    dockerfile COPY命令失效
    mysql排序字段值相等时,分页数据重复
    go使用json包Marshal方法得到异常结果[123 125]
    Mysql知识点概览
    dockercompose安装
    docker安装
    Shell脚本执行报错:Syntax error: "(" unexpected
    二进制数的位运算,角色权限,多种账号来源
  • 原文地址:https://www.cnblogs.com/pyyu/p/6925606.html
Copyright © 2011-2022 走看看