`apt purge` does not remove /var/lib/docker

Bug #1906959 reported by DarkTrick
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
docker.io (Ubuntu)
New
Undecided
Unassigned

Bug Description

Preface
========
- I'm filing this against docker.io, but it might as well be a problem with apt.
- I experienced this with the docker.io package, but I can imagine, that there are other packages out there, that have exactly the same problem. Please read this report as an example for a perhaps generic problem.

What happened:
===============
- `apt purge docker.io` does not remove docker's file directory `/var/lib/docker`. Therefore previously used images and other files will be left on the system. This might be expected using `apt remove`, but `apt purge` should remove "config files" as well.
- The sysadmin does not get any messages, that there are files left on the system.

Generic Problem:
================
apt-get is supposed to manage files on a ubuntu machine. It fails to meet its goal in this case.

Concrete description:
======================
- This might be a difficult case, as docker images can be seen as "user files" (not config files). It would not be the right thing to remove those files.
- The general user does probably not know about this directory. This is a very potential file graveyard on the system.
- Upon installing no one tells the admin (in a clear, informative way), that there will be files create in `/var/lib/docker`. The information is hidden from the user. In that case, apt should be responsible for doing something about these files, if they get deleted.

Suggestions / Solution
========================
(I don't have *the* solution for this problem. I guess it's necessary to discuss what's the right thing to do)

My idea: Put them in $HOME/docker (or similar) instead of /var/lib/docker. (yes, they might be seen as "system wide user files", but I think real admins know how they could config paths and change the location while simple users immediately see that there's a `docker` folder in their home directory)

Ubuntu 20.10

docker.io:
  Installed: (none)
  Candidate: 19.03.13-0ubuntu3
  Version table:
     19.03.13-0ubuntu3 500
        500 http://archive.ubuntu.com/ubuntu groovy/universe amd64 Packages
        100 /var/lib/dpkg/status

ProblemType: Bug
DistroRelease: Ubuntu 20.10
Package: docker.io (not installed)
ProcVersionSignature: Ubuntu 5.8.0-32.34-generic 5.8.18
Uname: Linux 5.8.0-32-generic x86_64
ApportVersion: 2.20.11-0ubuntu50.2
Architecture: amd64
CasperMD5CheckResult: skip
CurrentDesktop: XFCE
Date: Sun Dec 6 08:00:37 2020
SourcePackage: docker.io
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
DarkTrick (darktrick1337) wrote :
Revision history for this message
Tianon Gravi (tianon) wrote :

This confuses me, because this is already implemented?

- https://git.launchpad.net/ubuntu/+source/docker.io/tree/debian/docker.io.prerm?h=applied/ubuntu/devel
- https://git.launchpad.net/ubuntu/+source/docker.io/tree/debian/docker.io.postrm?h=applied/ubuntu/devel

It was added ~four years ago in 1.11.2-0ubuntu6:

  docker.io (1.11.2-0ubuntu6) yakkety; urgency=medium

    ...
      - remove "/var/lib/docker" on purge
    ...

   -- Tianon Gravi <email address hidden> Fri, 19 Aug 2016 10:15:14 -0700

It sounds like maybe there's a bug where this isn't working correctly in all cases?

Revision history for this message
Tianon Gravi (tianon) wrote :

Just to verify, I installed docker.io version 19.03.8-0ubuntu1.20.04.1, started up dockerd, verified /var/lib/docker got some content in it, and then stopped dockerd and ran "apt purge docker.io", and "/var/lib/docker" was properly emptied. It was not removed completely (in case it's a mount point or something similar), but there's no content in it (left as just an empty directory).

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.