to be
a problem slover

centos安装docker

概述

本文介绍在centos下如何安装docker

安装依赖

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

添加docker源

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

安装docker

sudo yum install docker-ce  

卸载旧版本(可选)

如果安装过程中有类似报错是因为有旧版本

Transaction check error:
  file /usr/bin/docker from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
  file /usr/bin/docker-containerd from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
  file /usr/bin/docker-containerd-shim from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
  file /usr/bin/dockerd from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64

卸载旧版本

sudo yum erase docker-engine-selinux
sudo yum erase docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64

或者

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

然后再重试安装

sudo yum install docker-ce  

查看docker版本

docker -v

启动docker

systemctl start docker

开机默认启动docker

systemctl enable docker

检查docker运行状态

systemctl status docker

验证docker安装

跑一个docker hello world

docker run hello-world

安装特定版本docker

查询有哪些可安装版本

yum list docker-ce --showduplicates | sort -r

如果不加--showduplicates 则只会显示最新版本
sort -r 降序排列

安装特定版本

sudo yum install docker-ce-<VERSION STRING>

Last Updated on

赞(1) 打赏
欢迎转载,注明出处:刘世明的博客 » centos安装docker

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下作者

支付宝扫一扫打赏

微信扫一扫打赏