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

    卸载旧版本

    较旧版本的Docker被称为dockerdocker-engine如果已安装这些,请卸载它们以及相关的依赖项。

    yum remove docker 
                      docker-client 
                      docker-client-latest 
                      docker-common 
                      docker-latest 
                      docker-latest-logrotate 
                      docker-logrotate 
                      docker-selinux 
                      docker-engine-selinux 
                      docker-engine

    使用存储库安装

    在新主机上首次安装Docker CE之前,需要设置Docker存储库。之后,您可以从存储库安装和更新Docker。

    设置存储库

    1. 安装所需的包。yum-utils提供了yum-config-manager 效用,并device-mapper-persistent-datalvm2由需要 devicemapper存储驱动程序。

      sudo yum install -y yum-utils 
        device-mapper-persistent-data 
        lvm2
    2. 使用以下命令设置稳定存储库。即使您还想从边缘测试存储库安装构建,您始终需要稳定的存储 库。
       sudo yum-config-manager 
          --add-repo 
          https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

    安装DOCKER CE

    1. 安装最新版本的Docker CE,或转到下一步安装特定版本:

      sudo yum install docker-ce
    2. 启动Docker。
      sudo systemctl start docker
    3. docker通过运行hello-world 映像验证是否已正确安装
      sudo docker run hello-world

    测试Docker版本

    1. 运行docker --version并确保您拥有受支持的Docker版本:

      docker --version
      
      Docker version 17.12.0-ce, build c97c6d6
    2. 运行docker info或(docker version--)查看有关docker安装的更多详细信息:
      docker info
      
      Containers: 0
       Running: 0
       Paused: 0
       Stopped: 0
      Images: 0
      Server Version: 17.12.0-ce
      Storage Driver: overlay2
      ...



    测试Docker安装

    1. 通过运行简单的Docker镜像hello-world来测试您的安装是否有效 

      docker run hello-world
      
      Unable to find image 'hello-world:latest' locally
      latest: Pulling from library/hello-world
      ca4f61b1923c: Pull complete
      Digest: sha256:ca0eeb6fb05351dfc8759c20733c91def84cb8007aa89a5bf606bc8b315b9fc7
      Status: Downloaded newer image for hello-world:latest
      
      Hello from Docker!
      This message shows that your installation appears to be working correctly.
      ...
    2. 列出hello-world下载到您的计算机图像:
      docker image ls
    3. 列出hello-world在显示其消息后退出容器(由图像生成)。如果它仍在运行,您将不需要--all选项:
      docker container ls --all
      
      CONTAINER ID     IMAGE           COMMAND      CREATED            STATUS
      54f4984ed6a8     hello-world     "/hello"     20 seconds ago     Exited (0) 19 seconds ago
    4. 进入容器
      docker exec -it 容器ID /bin/bash #容器必须是启动状态

    回顾和备忘单

    ## 列出Docker CLI命令
    docker
    docker container --help
    
    ## 显示Docker版本和信息
    docker --version
    docker version
    docker info
    
    ## 执行Docker镜像
    docker run hello-world
    
    ## 列出Docker镜像
    docker image ls
    
    ## 列出Docker容器 (running, all, all in quiet mode)
    docker container ls
    docker container ls --all
    docker container ls -aq

  • 相关阅读:
    [20190415]10g下那些latch是共享的.txt
    [20190415]11g下那些latch是共享的.txt
    [20190409]pre_page_sga=true与连接缓慢的问题.txt
    [20190402]Library Cache mutex.txt
    scrapy简单使用方法
    PHP多进程系列笔(转)
    RdKafka文档翻译
    python判断字符串中是否包含子字符串
    python 逐行读取txt文件
    redis使用watch完成秒杀抢购功能(转)
  • 原文地址:https://www.cnblogs.com/jiangwenhui/p/10075611.html
Copyright © 2011-2022 走看看