01-Docker-Ubuntu下docker安装及卸载

本文详细介绍了如何在Ubuntu系统中卸载旧版本的Docker,设置Docker仓库,安装Docker Engine Community以及验证安装是否成功。通过执行一系列命令,包括添加GPG密钥,设置稳定版仓库,安装和验证Docker,用户可以顺利进行Docker的安装。此外,还提供了卸载Docker的步骤,包括删除相关包,清理配置和目录,确保Docker彻底移除。
摘要由CSDN通过智能技术生成

目录

安装

  卸载旧版本(如未安装过直接跳过此步骤)

  设置仓库

  安装 Docker Engine-Community 

卸载

其他


安装

  卸载旧版本(如未安装过直接跳过此步骤)

sudo apt-get remove docker docker-engine docker.io containerd runc

  设置仓库

  • 更新软件源
 sudo apt-get update
  • 安装依赖包
sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
  • 添加 Docker 的官方 GPG 密钥:返回OK证明成功
 curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
  • 设置稳定版仓库
sudo add-apt-repository \
   "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \
  $(lsb_release -cs) \
  stable"

   安装 Docker Engine-Community 

  • 更新软件源
 sudo apt-get update
  • 安装最新版本的 Docker Engine-Community 和 containerd
sudo apt-get install docker-ce docker-ce-cli containerd.io
  • 验证安装是否成功: sudo docker run hello-world
执行:sudo docker run hello-world

返回如下内容说明安装成功!

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f
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/




卸载

  • 删除docker及其安装时自动安装的所有包
sudo apt-get autoremove docker docker-ce docker-engine  docker.io  containerd runc
  • 查看docker其他没有卸载软件
dpkg -l | grep docker
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P 
  • 卸载没有删除的docker相关插件(根据上一个命令返回的值)
sudo apt-get autoremove docker-ce-*  #后面要删除的是根据上个命令返回的值
  • 删除docker的相关配置&目录
 sudo rm -rf /etc/systemd/system/docker.service.d
 sudo rm -rf /var/lib/docker
  •  验证删除是否成功,找不docker命令说明卸载docker成功
docker --version

其他

  • 自动安装:curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱学习de测试小白

你的鼓励将是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值