0

I've tried to uninstall docker and failed because I am not able to remove this dir /var/lib/docker and it gives me this error:

(base) [xxx@xxx ~]$ sudo rm -rf /var/lib/docker/
rm: cannot remove ‘/var/lib/docker/containers/ca556f26e3680b5826300d72f83bfb507d4b0bfc399f22358baa46721e4c9366/shm’: Device or resource busy
rm: cannot remove ‘/var/lib/docker/overlay2/8d3fdb603781fc29fd02c49be5cf67be49b578a3bc92cc010ab308a037499e8b/merged’: Device or resource busy

I followed this answer because it had a very similar issue to mine. But if I check with lsof or fuser commands I get no output:

(base) [xxx@xxx ~]$ sudo lsof +D /var/lib/docker/

(base) [xxx@xxx ~]$ sudo /sbin/fuser /var/lib/docker/

Mount doesn't work as well:

(base) [xxx@xxx ~]$ sudo umount /var/lib/docker/containers/ca556f26e3680b5826300d72f83bfb507d4b0bfc399f22358baa46721e4c9366/shm
umount: /var/lib/docker/containers/ca556f26e3680b5826300d72f83bfb507d4b0bfc399f22358baa46721e4c9366/shm: not mounted

However, if I check with option `-m' to find resources utilized with this filesystem I get a dozen processes listed:

(base) [xxx@xxx ~]$ sudo /sbin/fuser -m /var/lib/docker/
/var/lib/docker:         1rce     2rc     3rc     5rc     8rc     9rc    10rc    11rc    12rc    13rc    14rc    16rc    17rc    18rc    19rc    21rc    22rc    23rc    24rc    26rc    27rc    28rc    29rc    31rc    32rc    33rc    34rc    36rc    37rc    38rc    39rc    41rc    42rc    43rc    44rc    46rc    47rc    48rc    49rc    51rc    52rc    53rc    54rc    56rc    57rc    58rc    59rc    61rc    62rc    63rc    64rc    66rc    67rc    68rc    69rc    71rc    72rc    73rc    74rc    76rc    77rc    78rc    79rc    80rc    81rc    82rc    83rc    84rc    86rc    87rc    88rc    89rc    91rc    92rc    93rc    94rc    96rc    97rc    98rc    99rc   101rc   103rc   104rc   105rc   107rc   108rc   109rc   110rc   112rc   113rc   114rc   115rc   117rc   118rc   119rc   120rc   122rc   123rc   124rc   125rc   127rc   128rc   129rc   130rc   132rc   133rc   134rc   135rc   137rc   138rc   139rc   140rc   142rc   143rc   144rc   145rc   147rc   148rc   149rc   150rc   152rc   153rc   154rc   155rc   157rc   158rc   159rc   160rc   162rc   163rc   164rc   165rc   167rc   168rc   169rc   170rc   172rc   173rc   174rc   175rc   177rc   178rc   179rc   180rc   182rc   183rc   184rc   185rc   187rc   188rc   189rc   190rc   192rc   193rc   194rc   195rc   197rc   198rc   199rc   200rc   202rc   203rc   204rc   205rc   206rc   207rc   208rc   209rc   210rc   212rc   213rc   214rc   215rc   217rc   218rc   219rc   220rc   222rc   223rc   224rc   225rc   227rc   228rc   229rc   230rc   232rc   233rc   234rc   235rc   237rc   238rc   239rc   240rc   242rc   243rc   244rc   245rc   247rc   248rc   249rc   250rc   252rc   253rc   254rc   255rc   257rc   258rc   259rc   260rc   262rc   263rc   264rc   265rc   267rc   268rc   269rc   270rc   272rc   273rc   274rc   275rc   277rc   278rc   279rc   280rc   282rc   283rc   284rc   285rc   287rc   288rc   289rc   290rc   292rc   293rc   294rc   295rc   297rc   298rc   299rc   300rc   302rc   303rc   304rc   305rc   307rc   308rc   309rc   310rc   312rc   313rc   314rc   315rc   317rc   318rc   319rc   320rc   322rc   323rc   324rc   325rc   327rc   328rc   329rc   330rc   332rc   333rc   334rc   335rc   337rc   338rc   339rc   340rc   342rc   343rc   344rc   345rc   347rc   348rc   349rc   350rc   352rc   353rc   354rc   355rc   357rc   358rc   359rc   360rc   362rc   363rc   364rc   365rc   367rc   371rc   372rc   373rc   374rc   375rc   376rc   378rc   380rc   385rc   386rc   387rc   388rc   389rc   390rc   398rc   401rc   406rc   407rc   427rc   463rc   465rc   660rc   667rc   672rc   673rc   675rc   676rc   678rc   679rc   681rc   683rc   684rc   685rc   686rc   690rc   691rc   692rc   693rc   694rc   695rc   696rc   701rc   702rc   703rc   704rc   718rc   719rc  1074rc  1075rc  1093rc  1094rc  1163rc  1165rc  1166rc  1168rce  1195rce  1197rce  1273rc  1331rc  1349rc  1359rc  1360rc  1539rc  1603rc  1604rc  1605rc  1606rc  1607rc  1608rc  1610rc  1650rc  1675rc  1676rc  1678rc  1679rc  1680rc  1681rc  1696rc  1697rc  1698rc  1699rc  1700rc  1701rc  1702rc  1703rc  1704rc  1707rc  1709rc  1710rc  1712rc  1723rc  1724rc  1741rce  1767rce  1781rce  1813rce  1815rce  1816rce  1818rce  1829rce  1960rc  1961rc  1962rc  1963rc  1964rc  1965rc  1966rc  1967rc  1968rc  1969rc  1970rc  1971rc  1972rc  1974rc  2226re  2273rc  2275rce  2276rce  2278rce  2280rce  2282rce  2289rce  2291rce  2293rce  2297re  2298rce  2299re  2323rce  2324rce  2325rce  2363rce  2567rce  2610rc  2617rce  2649rc  2697rc  2698rc  2699rc  2700rc  2705rc  2716rc  2717rc  2725rc  2726rc  2727rc  2728rc  2729rc  3187rc  3226rc  3227rc  3230rce  3235rc  3360rc  3361rc  3440rc  3503rc  3574rc  3606rc  3619rc  3651rc  3658rc  3683rc  3694rc  3705rc  3771rc  3895rc  4052rc  4282rc  4444rc  4494rc  4705rc  4751rc  4827rc  5135rc  5296rm  5363rm  5588rc  5870rc  6032rc  6073rc  6230rc  6526rc  6768rc  6833rc  7025rc  7408rc  7697rc  8559rc  8634rc  8901rc  9095rc  9132rc 10928rc 11053rc 11453rc 11595rc 11955rm 12127re 12362rc 12466rc 12546rc 13045rc 13399rm 13515rc 13821rc 13852rc 13894rce 13901rce 14285rc 15200re 15201re 15729re 15979rc 15988rm 16011rm 16291rm 16400rm 16470rm 16746rm 16810rc 17054rm 17109rm 17351rm 17480rm 17536rm 17686rm 18020re 18310rm 18332rm 18402rm 18434rc 18442rm 18495rm 18548re 18679rm 18754rc 19076re 20986rc 21802rc 21932rc 22072rc 22170rce 22173rce 22174re 22215re 22287re 22288re 22376rc 22842rc 23951rc 24139rm 24410re 24887rce 24954rc 25049re 25569rc 25799rce 25821rce 25833rc 25967rce 25975rc 25977rce 25978re 26007rc 26009rce 26024rce 26074rce 26142rc 26193rc 26242rce 26325rm 26438rce 26454rm 26608rce 26682rce 26684rce 26726rce 26756rce 26760rce 26767rce 26809re 27027rc 27378rc 27393rc 28586rc 28836rm 29475rc 30047rce 30049rce 30050re 30084rm 30106rm 30108rc 30120rm 30137rm 30150rm 30176rc 30365rm 30675rc 30800rc 31205rc 31229rm 31447rc 31522rc 31747rc 31999rc 32205rc 32213rc 32298rm 32320rc 32955rc 33066rc 33127rm 33139rm 33152re 33153re 33641re 33667rc 33681re 33932rc 34463rc 34764rc 36432rc 37098rc 37327rm 37362rc 37426rm 37558rc 37711rc 38325rc 39116rm 39769rc 39918rc 40554rc 40646rm 40781rm 40783rm 41528rc 41959re 42332re 42463rm 42775rm 42798rm 42883rm 43052rm 43053rm 43054rm 43055rm 43056rm 43057rm 43058rm 43059rm 43060rm 43061rm 43062rm 43063rm 43064rm 43065rm 43066rm 43067rm 43069rm 43070rm 43071rm 43072rm 43073rm 43074rm 43075rm 43076rm 43077rm 43078rm 43079rm 44351rm 44433re 45379rc 46560rc 46721rm 47895rm 48099rm 48169rm 49149re 50318rc 50357rm 51144rc 51377rc 51801rm 52251rc 52283rc 52674rm 53514rc 53589rc 53971rm 54141rm 54437rc 54446rm 54543rm 54588rm 54690rc 54727rm 54804rm 54907rc 54921rc 55328rc 56035rc 56153rc 56476rm 56747rc 57369rm 57437rc 57440rc 57709rc 57778rc 57840re 57976rc 58069rm 58150rc 58533rc 58847rc 58863rc 58895rm 59054rm 59096rm 59258rm 59282rm 59333rm 59501rm 59762rc 60139rm 60176rm 60196rm 60285rm 60324rc 60780rm 60867rc 61218rm 61290rc 61321rm 61466rm 61469rm 61491rm 61610rm 61663rc 61880rm 61983re 62228rc 62363rc 62669re 62911rc 63106rc 63274rc 64263rc 64626rm 64918rm 64974rc 65734rc 66707rm 67083rc 67775rc 68263re 68649re 68899rc 69805re 70299re 70761rm 72632rc 72982re 73039rc 73567rm 73592rm

That represents most of the processes on the server, and I am not sure how they are all assigned to docker lib dir? It must be some kind of confusion, at least for me.

Hopefully, someone can help me to resolve this issue! Thanks a lot.

EDIT: I deleted docker prior to this step following instructions from here: uninstall docker

Galilej25
  • 1
  • 1

1 Answers1

0

If you're trying to remove the docker folder, you need to stop all docker containers first.

sudo docker stop $(sudo docker ps -a -q)

Then you can remove the folder.

sudo rm -rf /var/lib/docker
  • Thank you @bluescreen, however I do not have docker anymore, as it has been deleted prior to this step. ```(base) [xxx@xxx ~]$ sudo docker stop $(sudo docker ps -a -q) sudo: docker: command not found sudo: docker: command not found ``` – Galilej25 Jun 29 '22 at 07:40
  • check `sudo fuser -m -v /var/lib/docker/containers/ca556f26e3680b5826300d72f83bfb507d4b0bfc399f22358baa46721e4c9366/shm` – bluescreen Jun 29 '22 at 07:55
  • It lists a lot of the processes including some system kernel one's ``` sudo fuser -m -v /var/lib/docker/containers/ca556f26e3680b5826300d72f83bfb507d4b0bfc399f22358baa46721e4c9366/shm | wc -l USER PID ACCESS COMMAND /var/lib/docker/containers/ca556f26e3680b5826300d72f83bfb507d4b0bfc399f22358baa46721e4c9366/shm: root mount / root .rce. systemd root .rc.. kthreadd root .rc.. ksoftirqd/0 .. ``` – Galilej25 Jun 29 '22 at 07:57
  • try `sudo rm -rf /var/lib/docker/containers/ca556f26e3680b5826300d72f83bfb507d4b0bfc399f22358baa46721e4c9366 ` – bluescreen Jun 29 '22 at 07:58
  • @Galilej25 or this `sudo rm -rf /var/lib/docker/overlay2/8d3fdb603781fc29fd02c49be5cf67be49b578a3bc92cc010ab308a037499e8b/diff/ca` – bluescreen Jun 29 '22 at 08:00
  • Nope, not even that one is working: `rm: cannot remove ‘/var/lib/docker/containers/ca556f26e3680b5826300d72f83bfb507d4b0bfc399f22358baa46721e4c9366/shm’: Device or resource busy` – Galilej25 Jun 29 '22 at 08:01
  • This one worked: `sudo rm -rf /var/lib/docker/overlay2/8d3fdb603781fc29fd02c49be5cf67be49b578a3bc92cc010ab308a037499e8b/diff/ca` ! – Galilej25 Jun 29 '22 at 08:02
  • Problem solved? – bluescreen Jun 29 '22 at 08:05
  • No, unfortunately not yet. I am still not able to delete docker dir – Galilej25 Jun 29 '22 at 08:44
  • Try: `systemctl stop docker` `systemctl disable docker` `rm -rf /var/lib/docker` – bluescreen Jun 29 '22 at 10:44
  • Docker has been deleted from the servers, therefore I can't do anything to stop it/disable it. `sudo systemctl disable docker Failed to execute operation: No such file or directory` – Galilej25 Jun 29 '22 at 11:20
  • Even after I installed the newest docker version I am not able to delete this container. Also, it is not visible in `docker ps -a` – Galilej25 Jun 29 '22 at 13:21
  • Maybe try it: `docker rmi $(docker images -q)` again – bluescreen Jun 29 '22 at 13:38
  • No, even with this it doesn't work, because it can't map container `ca556f26e3680b` , nor associated image with the current version of docker. It became invisible, most probably it is not in the registry anymore. – Galilej25 Jun 29 '22 at 14:10