Docker是一種開源的容器化技術(shù),它可以讓應(yīng)用程序在隔離的環(huán)境中運(yùn)行。Docker的使用非常普及,但是有時(shí)候我們也會(huì)遇到問題,比如卸載Docker時(shí)會(huì)出現(xiàn)報(bào)錯(cuò)。接下來,我們就來看看如何解決Docker卸載報(bào)錯(cuò)的問題。
$ sudo apt-get purge docker-ce Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: aufs-tools cgroupfs-mount containerd pigz Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: docker-ce* 0 upgraded, 0 newly installed, 1 to remove and 711 not upgraded. After this operation, 1,845 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 47902 files and directories currently installed.) Removing docker-ce (5:18.09.1~3-0~ubuntu-bionic) ... Failed to stop docker.service: Unit docker.service not loaded. dpkg: error processing package docker-ce (--purge): installed docker-ce package pre-removal script subprocess returned error exit status 5 dpkg: error while cleaning up: installed docker-ce package post-installation script subprocess returned error exit status 1 Errors were encountered while processing: docker-ce E: Sub-process /usr/bin/dpkg returned an error code (1)
我們可以看到,在運(yùn)行卸載命令時(shí),Docker服務(wù)無法停止,導(dǎo)致報(bào)錯(cuò)。接下來,我們應(yīng)該如何進(jìn)行解決呢?
首先,我們需要檢查Docker服務(wù)是否正在運(yùn)行。可以使用以下命令進(jìn)行檢查:
$ sudo systemctl status docker
如果Docker服務(wù)正在運(yùn)行,我們需要停止它,可以使用以下命令:
$ sudo systemctl stop docker
現(xiàn)在再次運(yùn)行卸載命令,即可成功卸載Docker:
$ sudo apt-get purge docker-ce Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: aufs-tools cgroupfs-mount containerd pigz Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: docker-ce* 0 upgraded, 0 newly installed, 1 to remove and 711 not upgraded. After this operation, 1,845 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 47902 files and directories currently installed.) Removing docker-ce (5:18.09.1~3-0~ubuntu-bionic) ... Processing triggers for man-db (2.8.3-2ubuntu0.1) ... Processing triggers for systemd (237-3ubuntu10.39) ...
現(xiàn)在,我們已經(jīng)成功卸載了Docker。如果您還遇到其他問題,可以在Docker的官方文檔中尋找解決方案。