打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
记录下在CentOS7中安装Docker CE

记录下在CentOS7中安装Docker CE

1. 卸载系统中可能存在的老版本

  •   在CentOS中,老版本Docker的软件包名是docker或docker-engine,而Docker CE的软件包名称是docker-ce。因此,若已安装过老版本的Docker,需使用如下命令卸载

    • //复制如下代码,在Linux上直接执行

      sudo yum remove docker \
      docker-common \
      docker-selinux \
      docker-engine

  • 需要注意的是,执行该命令只会卸载Docker本身,不会删除Docker存储的文件,例如镜像、容器、卷以及网络文件等。这些文件保存在/var/lib/docker目录中,需要手动删除。

2. 开始安装docker CE

  • 复制执行以下命令,安装Docker所需的包。其中:

    • yum-utils: 提供yum-conf ig-manager的工具;

    • device-mapper-persistent-data及lvm2: 是devicemapper存储驱动所需的包.

    • sudo yum install -y yum-utils device-mapper-persistent-data lvm2
  • 复制执行如下命令,安装stable仓库。必须安装stable仓库,即使你想安装edge或test仓库中的Docker构建版本。

    • sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

  • [可选]执行如下命令,启用edge及test仓库。edge/test仓库中其实也包含在了docker.repo文件中,但默认是禁用的,可使用以下命令启用

    • sudo yum-config-manager --enable docker-ce-edge  #启动edge仓库, 如果想要禁用将enable改为disable即可
      sudo yum-config-manager --enable docker-ce-test #启动test仓库
  • 复制执行以下命令,更新yum的包索引

    • sudo yum makecache fast
  • 复制执行如下命令即可安装最新版本的Docker CE

    • sudo yum install docker-ce
  • 启动docker

    • sudo systemctl start docker
  • 验证安装是否正确

    • Unable to find image 'hello-world:latest' locally
      latest: Pulling from library/hello-world
      b8dfde127a29: Pull complete 
      Digest: sha256:7d91b69e04a9029b99f3585aaaccae2baa80bcf318f4a5d2165a9898cd2dc0a1
      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://hub.docker.com/For more examples and ideas, visit:
       https://docs.docker.com/get-started/
    • sudo docker run hello-world
    • 返回结果如下

  • 卸载:

    • sudo yum remove docker-ce #卸载docker-ce
      sudo rm -rf /var/lib/docker #强制删除docker相关文件

使用脚本来安装Dockers

  •   依次执行如下命令:

    • curl -fsSL get.docker.com -o get-docker.sh
    •  sudo sh get-docker.sh
    • www.awaedu.com
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Centos7上如何安装docker
Docker 镜像详细讲解
centos7安装docker
linux下(centos7)docker安装
Docker国内Yum源和国内镜像仓库
Centos7安装docker
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服