linux安装Docker教程

准备工作

查看Linux版本的命令

lsb_release -a  查看效果

cat /etc/redhat-release 查看版本

https://docs.docker.com/engine/install/centos/

照着文档便可以开始安装。

安装Docker

1.手动档

手动分三步:卸载、设置仓库、安装。

1)卸载(新机pass)这里我不是root所以加了sudo

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

2)设置仓库

先安装依赖包

sudo yum install -y yum-utils

如果在国内建议换源,这里我用的官方。

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

较快的国内源

  • 阿里云:http: // mirrors.aliyun.com / docker-ce / linux / centos / docker-ce.repo
  • 清华大学源:https: // mirrors.tuna.tsinghua.edu.cn / docker-ce / linux / centos / docker-ce.repo

如果需要测试版本的Docker执行以下命令:

sudo yum-config-manager --enable docker-ce-test

出现如下画面代表成功

docker-ce为社区免费版本。稍等片刻,docker即可安装成功。

sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

但安装完成之后的默认是未启动的,需要进行启动操作。

sudo systemctl enable docker
sudo systemctl start docker

通过运行hello-world镜像来验证是否正确安装了

// 拉取镜像
sudo docker pull hello-world
// 执行hello-world
sudo docker run hello-world

执行之后,控制台显示如下信息,则说明Docker安装和启动成功:

2.自动档

官方的一键安装方式:

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

国内 daocloud一键安装命令:

curl -sSL https://get.daocloud.io/docker | sh

删除Docker

删除安装包:

sudo yum remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras

删除镜像、容器、配置文件等内容:

sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值