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

简介: 01-Docker-Ubuntu下docker安装及卸载

安装

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

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

 设置仓库

  • 更新软件源
sudo apt-get update
  • 安装依赖包
1. sudo apt-get install \
2.     ca-certificates \
3.     curl \
4.     gnupg \
5.     lsb-release
  • 添加 Docker 的官方 GPG 密钥:返回OK证明成功
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
  • 设置稳定版仓库
1. sudo add-apt-repository \
2. "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \
3.   $(lsb_release -cs) \
4.   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
1. 执行:sudo docker run hello-world
2. 
3. 返回如下内容说明安装成功!
4. 
5. Unable to find image 'hello-world:latest' locally
6. latest: Pulling from library/hello-world
7. 2db29710123e: Pull complete 
8. Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f
9. Status: Downloaded newer image for hello-world:latest
10. 
11. Hello from Docker!
12. This message shows that your installation appears to be working correctly.
13. 
14. To generate this message, Docker took the following steps:
15. 1. The Docker client contacted the Docker daemon.
16. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
17.     (amd64)
18. 3. The Docker daemon created a new container from that image which runs the
19.     executable that produces the output you are currently reading.
20. 4. The Docker daemon streamed that output to the Docker client, which sent it
21. to your terminal.
22. 
23. To try something more ambitious, you can run an Ubuntu container with:
24.  $ docker run -it ubuntu bash
25. 
26. Share images, automate workflows, and more with a free Docker ID:
27.  https://hub.docker.com/
28. 
29. For more examples and ideas, visit:
30. https://docs.docker.com/get-started/
31. 
32. 
33. 
34.

卸载

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

其他

相关文章
|
7天前
|
Linux 虚拟化 Docker
Windows10安装Docker Desktop(大妈看了都会)
Windows10安装Docker Desktop(大妈看了都会)
156 2
|
11天前
|
Ubuntu Linux
在Linux (Ubuntu 16) 下安装LabVIEW
在Linux (Ubuntu 16) 下安装LabVIEW
29 0
|
3天前
|
存储 Linux 网络安全
Centos安装Docker的详细安装步骤,Docker相关组件:docker-ce-cli、docker-ce和containerd.io的区别
Centos安装Docker的详细安装步骤,Docker相关组件:docker-ce-cli、docker-ce和containerd.io的区别;CentOS7安装DockerCompose;Docker镜像仓库
|
1天前
|
Docker 容器
docker安装minio
以上就是在Docker中安装MinIO的步骤。
9 2
|
1天前
|
Docker 容器
docker desktop安装es并连接elasticsearch-head:5
以上就是在Docker Desktop上安装Elasticsearch并连接Elasticsearch-head:5的步骤。
11 2
|
4天前
|
应用服务中间件 API 数据库
Docker 安装 KONG 带你玩转 API 网关
**摘要:** 在微服务架构中,API网关Kong作为流行开源选择,提供身份验证、安全和流量控制等功能。通过Docker部署Kong简单高效。步骤包括:创建Docker网络,部署PostgreSQL数据库,初始化Kong数据库,启动Kong容器,并检查运行状态。此外,安装Konga管理界面便于直观管理Kong。使用Docker命令行,逐步设置环境变量和网络连接,即可完成安装。当不再需要时,可清理相关容器和网络。Kong结合Konga,为API管理提供强大且用户友好的解决方案。
16 1
|
7天前
|
存储 Ubuntu Java
【Linux】已解决:Ubuntu虚拟机安装Java/JDK
【Linux】已解决:Ubuntu虚拟机安装Java/JDK
13 1
|
4天前
|
Ubuntu C语言
【Ubuntu20.04】安装gcc11 g++11, Ubuntu18.04
以上就是在Ubuntu 20.04和Ubuntu 18.04上安装gcc11和g++11的步骤。
7 0
|
10天前
|
Ubuntu 关系型数据库 MySQL
MySQL5.7在Ubuntu安装[单机软件],第一步登录root,sudo su -
MySQL5.7在Ubuntu安装[单机软件],第一步登录root,sudo su -
|
10天前
|
Ubuntu 关系型数据库 MySQL