zoukankan      html  css  js  c++  java
  • 【CentOS】安装Docker教程

    前提条件

    Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。

    Docker 运行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系统为64位、系统内核版本为 2.6.32-431 或者更高版本。

    首先, 查看系统是否支持:

                   image

    Docker有两种方式安装:

    1. 脚本安装
    2. Yum包安装

    安装前注意:

    1. 本文针对CentOS 7 去安装
    2. 如果太久或者是特殊系统不要yum update
    3. 必需要root权限

    一、Yum包安装

    (1) 添加 docker,Yum源
    [root@localhost ~]# sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
    > [dockerrepo]
    > name=Docker Repository
    > baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
    > enabled=1
    > gpgcheck=1
    > gpgkey=https://yum.dockerproject.org/gpg
    > EOF
    [dockerrepo]
    name=Docker Repository
    baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
    enabled=1
    gpgcheck=1
    gpgkey=https://yum.dockerproject.org/gpg
    (2) 安装 docker包
    [root@localhost ~]# yum install docker-engine
    (3) 启动守护 docker进程
    [root@localhost ~]# service docker start
    Redirecting to /bin/systemctl start  docker.service
    (4) 测试
    [root@localhost ~]# docker run hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    ca4f61b1923c: Pull complete 
    Digest: sha256:97ce6fa4b6cdc0790cda65fe7290b74cfebd9fa0c9b8c38e979330d547d22ce1
    Status: Downloaded newer image for hello-world:latest
    
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    
    To generate this message, Docker took the following steps:
     1. The Docker client contacted the Docker daemon.
     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
        (amd64)
     3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
     4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.
    
    To try something more ambitious, you can run an Ubuntu container with:
     $ docker run -it ubuntu bash
    
    Share images, automate workflows, and more with a free Docker ID:
     https://cloud.docker.com/
    
    For more examples and ideas, visit:
     https://docs.docker.com/engine/userguide/
    (5) 镜像加速 (可选)
     vim /etc/docker/daemon.json
    
    {
      "registry-mirrors": ["http://hub-mirror.c.163.com"]
    }
    (6) 开机启动
    [root@localhost ~]# systemctl enable docker.service

    二、脚本安装 (感觉不太靠谱, 不推荐)

    (1)  yum update

    (2)  curl -sSL https://get.docker.com/ | sh

    (3)  service docker start

    (4)  docker run hello-world

    启动时候会出现的错误:

      Job for docker.service failed. See 'systemctl status docker.service' and 'journalctl -xn' for details.

    1: 防火墙之类的,

    2: yum -y install docker

    推荐文档:

    http://www.runoob.com/docker/centos-docker-install.html

    http://www.docker.org.cn/book/install/supported-platform-17.html

  • 相关阅读:
    几种归一化方法的概念及python实现
    python 中几种基本的矩阵操作应用
    exec 命令简单用法 和 find 搭配用法示例
    使用git在github上创建新工程
    gcc编译参数详解概述
    此心不明,能有何为
    多个文件目录下Makefile的写法
    《高效能程序员的修炼》读后思考之写作的重要性
    音频格式RAW和PCM区别和联系
    SWIG 基本概念和入门
  • 原文地址:https://www.cnblogs.com/EddieBlog/p/8796924.html
Copyright © 2011-2022 走看看