docker uninstall and install

docker uninstall

#卸载docker
sudo apt-get remove docker
sudo apt-get remove docker-engine docker.io
#卸载docker-ce
sudo apt-get remove docker-ce
#卸载安装依赖
sudo apt-get autoremove --purge docker-ce
上面的命令不会移除镜像、容器、卷或者是用户创建的配置文件,如果想卸载所有的镜像、容器、卷,可运行
rm -rf /var/lib/docker

install docekr

首先安装依赖
sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
信任 Docker 的 GPG 公钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
对于 amd64 架构的计算机,添加软件仓库

sudo add-apt-repository \
 "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"
最后安装
sudo apt-get update
sudo apt-get install docker-ce
把当前用户加到docker用户组中
添加docker用户组

sudo groupadd docker

把自己加到docker用户组中

#myusername   是你自己的用户名
sudo gpasswd -a myusername docker

重启docker后台服务

sudo service docker restart
切换当前用户到新group

newgrp - docker
确定docker可以非sudo运行

docker ps

Method Two:

卸载旧版本
sudo apt-get remove docker docker-engine docker.io containerd runc
安装依赖包
sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
添加GPG key,并设置stable版本的仓库
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
apt-get安装
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
验证安装结果
sudo docker run --rm hello-world
--rm参数代表我们运行后随即删除这个容器,因为我们只需要这个容器输出一段信息而已。

执行后会输出类似这样的信息,说明已经安装成功:

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

The Docker client contacted the Docker daemon.
The Docker daemon pulled the “hello-world” image from the Docker Hub.
(amd64)
The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
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都要加一个sudo挺麻烦,我们将当前账号加入Docker组里面即可免sudo运行Docker:
sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo service docker restart
newgrp - docker

ubuntu completely clean uninstall docker

1. Delete a certain software and all packages that are automatically installed during installation

sudo apt-get autoremove docker docker-ce docker-engine  docker.io  containerd runc

2. Delete docker and others are not uninstalled

dpkg -l | grep docker
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P # Delete useless related configuration files

3. Uninstall the docker-related plug-ins that have not been deleted (combined with the actual situation of your computer)

sudo apt-get autoremove docker-ce-*

4. Delete the relevant configuration and directory of docker

 sudo rm -rf /etc/systemd/system/docker.service.d
 sudo rm -rf /var/lib/docker

5. Make sure docker is uninstalled

docker --version

Reference link: https://blog.csdn.net/qq_29935433/article/details/104781692

http://chason.me/docker-tutorial/

https://www.cnblogs.com/shmily3929/p/12085163.html

Supongo que te gusta

Origin blog.csdn.net/wzhrsh/article/details/116230165
Recomendado
Clasificación