Lost volumes after installing docker desktop on ubuntu

Hi I’ve been running Docker on my Ubuntu machine for a while to run a simple java backend/postgres database app. The data for the database is mounted in a volume and everything stood up with the following docker-compose file:

version: '3.4'

    image: postgres:14.1
    restart: on-failure
      - postgres-spring-data:/var/lib/postgresql/data

    image: some-spring-image
      SERVER_PORT: 8084
      - "8084:8084"
    restart: on-failure


I realised I needed to install buildx so that I could make the spring container image support arm64 as well as amd64. I installed docker desktop using the following guide: Install Docker Desktop on Ubuntu | Docker Documentation

After that, standing up my services reveals the volume has been emptied! No data exists in the postgres database any more.

I immediately looked in /var/lib/docker/volumes which shows a large number of volumes including my postgres-spring-data. The volume seems to be ~1.3GB large which seems way too much for an empty postgres database right?!

So then I thought maybe docker desktop was mounting the volume somewhere else and my volume was left in tact. But inspecting the container would suggest it is using that 1.3GB folder.

Can anyone tell me what’s going on here? Is there any way I can get my old postgres data back?
Thanks in advance.

EDIT: I’ve exec’d into the running postgres container and run SELECT oid as object_id, datname as database_name FROM pg_database; this has listed the following databases:

 object_id |   database_name   
     13757 | postgres
     16384 | my-database (New empty DB created by spring when it found no data)
         1 | template1
     13756 | template0

however in the postgres volume in /var/lib/docker/volumes/tooling_postgres-spring-data/_data/base we have the following folders (these should match OIDs of postgres databases):

- /1
- /13756
- /13757
- /50959 (Seemingly not known by running postgres. ~950mb)
- /pgsql_temp

This makes me think (hope!) that the volume mounted in the running postgres is not the same as the one i’m looking at in my filesystem… very odd.

Woah just seen the small print that docker desktop is running in a VM on linux. That would make a lot of sense now…
This should potentially be a slightly larger footnote on the linux installation page!

Nothing is lost. These two command will be your friends: docker context ls and docker context use ${context name} (of course with an existing context name from context ls)

1 Like

Thanks for the reply, that was indeed the thing to do. This is what I get for not reading the instructions fully :smile: