zoukankan      html  css  js  c++  java
  • Centos7 下安装docker

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

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

    通过 uname -r 命令查看你当前的内核版本(我的环境是centos7)

    移除旧的版本:

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

    报这个错误

    Another app is currently holding the yum lock; waiting for it to exit...
      The other application is: PackageKit
        Memory :  78 M RSS (568 MB VSZ)
        Started: Wed Oct 16 23:26:48 2019 - 00:11 ago
        State  : Sleeping, pid: 20211

    这样来解决:

    rm -rf /var/run/yum.pid

    再次运行就通过了

    装一些必要的系统工具:

    sudo yum install -y yum-utils device-mapper-persistent-data lvm2
     


    添加软件源信息:
    sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    更新 yum 缓存:
    sudo yum makecache fast

    安装 Docker-ce:
    sudo yum -y install docker-ce

     


    启动 Docker 后台服务
    sudo systemctl start docker



    测试运行 hello-world
    docker run hello-world


    由于没有hello-world这个镜像,所以会下载一个hello-world的镜像,并在容器内运行



    通过查看可以看到多了hello-world这个镜像

     

    同时可以查看一下容器

     

    使用脚本安装 Docker

    使用 sudoroot 权限登录 Centos。

    确保 yum 包更新到最新。

    sudo yum update

    执行 Docker 安装脚本

    curl -fsSL https://get.docker.com -o get-docker.sh
    sudo sh get-docker.sh

    执行这个脚本会添加 docker.repo 源并安装 Docker。



    启动 Docker 进程
    sudo systemctl start docker
    验证 docker 是否安装成功并在容器中执行一个测试的镜像。

    docker run --name hellobaidu  -d learn/ping ping www.baidu.com  //这是后台运行容器的方式


    下面这种方式直接运行容器
    docker run -it ubuntu bash

     


    删除容器

    如果你要删除的 container 还是运行状态,那么就要先把容器停止了
    docker container stop <container ID>


    找到需要删除的容器对应的  container ID 或者名字,进行删除:
    docker container rm  <container ID>


    先获取容器信息,可以看到,有两个容器是运行状态,是不能直接删除的,我们现在把没有运行的容器删除


    删除镜像

    删除镜像文件的方法和删除容器的方法是一样的,将删除容器命令中的container更改成image即可

    如果删除出错,这是由于镜像正在被容器使用,用命令停止容器,移除容器后,在移除镜像即可。














  • 相关阅读:
    java中的 equals 与 ==
    String类的内存分配
    SVN用命令行更换本地副本IP地址
    npoi 设置单元格格式
    net core 微服务框架 Viper 调用链路追踪
    打不死的小强 .net core 微服务 快速开发框架 Viper 限流
    net core 微服务 快速开发框架 Viper 初体验20201017
    Anno 框架 增加缓存、限流策略、事件总线、支持 thrift grpc 作为底层传输
    net core 微服务 快速开发框架
    Viper 微服务框架 编写一个hello world 插件02
  • 原文地址:https://www.cnblogs.com/braveym/p/11687069.html
Copyright © 2011-2022 走看看