0

I started using Docker recently and Docker was taking up too much space even after i prune all the dangling containers and images.

When is try to run sudo docker system prune --all -f it shows "container prune" requires API version 1.25, but the Docker daemon API version is 1.24 but clearly my Docker is at version 1.44When I run sudo docker version.

Every category is zero when I run docker system df.

I used Docker to spawn a Python container and installed libraries like Flask in it many times it also had the access to docker.sock to spawn new containers.

Is that taking up all the space?. If so, how to claim the space back?

Here's sudo docker info output

Client: Docker Engine - Community
 Version:    25.0.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2-desktop.5
    Path:     /usr/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.23.0-desktop.1
    Path:     /usr/lib/docker/cli-plugins/docker-compose
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /usr/lib/docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.20
    Path:     /usr/lib/docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.9
    Path:     /usr/lib/docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /usr/lib/docker/cli-plugins/docker-sbom
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     /usr/lib/docker/cli-plugins/docker-scan
  scout: Docker Scout (Docker Inc.)
    Version:  v1.0.9
    Path:     /usr/lib/docker/cli-plugins/docker-scout

Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 20.10.24 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: systemd Cgroup Version: 2 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc io.containerd.runc.v2 io.containerd.runtime.v1.linux Default Runtime: runc Init Binary: docker-init containerd version: 2806fc1057397dbaeefbea0e4e17bddfbd388f38 runc version: init version: de40ad0 Security Options: apparmor seccomp Profile: default cgroupns Kernel Version: 6.5.0-14-generic Operating System: Ubuntu Core 22 OSType: linux Architecture: x86_64 CPUs: 20 Total Memory: 15.24GiB Docker Root Dir: /var/snap/docker/common/var-lib-docker Debug Mode: false Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false

Artur Meinild
  • 26,018
An enthusiast
  • 111
  • 1
  • 3
  • Concerning the version issue, pls try updating docker compose first: https://stackoverflow.com/questions/61538216/docker-client-api-version-issue – Lorberta Jan 23 '24 at 11:56
  • I think the version issue is because there's both a .deb and a snap version of Docker installed. – Artur Meinild Jan 23 '24 at 12:39

2 Answers2

2

Your docker info command shows something "interesting" (read: wrong). It says:

Client: Docker Engine - Community
 Version:    25.0.0
...
   Path:     /usr/lib/docker/cli-plugins/docker-compose

But then it says:

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.24
 ...
 Docker Root Dir: /var/snap/docker/common/var-lib-docker

Coincidently, the client version matches the latest version from Docker repos, but the server version matches the latest stable snap version of Docker.

This, combined with the given paths (one has /usr/lib, the other has /var/snap), leads me to believe that you have Docker installed as both a snap package and a normal .deb package from the Docker repos.

My suggestion is to remove the snap package, and then maybe reinstall Docker to make sure everything is OK.

sudo snap remove docker
sudo apt-get install --reinstall docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Now I believe Docker should work correctly with only the latest version.

Also see this question, which is somewhat similar.

Artur Meinild
  • 26,018
  • Yeah now docker is working the issue was the one you said but still after reinstalling docker and running the prune again, it still is taking 15.24GiB is there any way to free this space? – An enthusiast Jan 23 '24 at 14:59
  • For disk space, please see if there are any files left inside /var/snap/docker/common/var-lib-docker. If yes, those can now be removed. – Artur Meinild Jan 23 '24 at 20:29
  • You should probably write up a new question, describing the new situation and problem. – Artur Meinild Jan 23 '24 at 20:29
2

Alternative reason: user is not part of docker group.

And docker system prune does not clearly state that, instead giving ambiguous "container prune" requires API version 1.25, but the Docker daemon API version is 1.24 error

Add user to docker group or use sudo.

  • 1
    Are you sure? OP was already using sudo, so the group membership didn't matter for them. And if a user who's not in the docker group tried docker system prune without sudo, I'd actually expect to see an error involving the Docker daemon's socket /var/run/docker.sock. To even get to the API mismatch error they'd need to be able to access that socket, which wouldn't work without root or the docker group membership. – muru Jan 30 '24 at 15:33
  • You are right, indeed, it works with sudo either way, just confirmed it.

    However, without sudo it is as described - which tells that this error is most probably not a root cause, but ambigous message, when client seems to unable to contact the socket.

    – Aleksejs Spiridonovs Jan 30 '24 at 15:57
  • Or you, like OP have the Docker daemon installed in two different ways, and only when you don't have permissions for accessing one of them do you see the error about version mismatch. – muru Jan 30 '24 at 16:02
  • 2
    sudo was exactly what I needed! Thanks! – NixonSparrow Feb 17 '24 at 07:14