0

I have a docker-compose.yml which I am using to deploy to a remote host from my local (Mac) machine using docker context. The compose config is as follows:

database:
    image: postgres:14.2
    restart: on-failure

    volumes:
      - ./db-data:/var/lib/postgresql/data

    environment:
      POSTGRES_DB: db
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres

In order to persist data, I have defined a volume ./db-data:/var/lib/postgresql/data. This db-data folder does not exist in my local machine. I want delete this mount completely because I don't want any of the previously persisted data. I know I can define a new volume directory but I would like to use the same directory name (db-data). I have tried the following:

  1. docker compose down --volume --remove-orphans - when I recreate new container, previously persisted data still exists
  2. There is no folder called ./db-data in my Mac working directory.
  3. I tried searching var/lib/docker in my Mac. But that directory does not exists.
  4. Docker for Mac app doesn't list any volumes
  5. There is no db-data in the remote host where the database is deployed
Vino
  • 2,111
  • 4
  • 22
  • 42
  • That syntax should cause a directory named `db-data` to exist on the system running the Docker daemon, and you should be able to just delete it with `rm -rf`. It will not create a named Docker volume; you will not be able to see this directory with `docker volume` commands. – David Maze Feb 28 '22 at 12:00

2 Answers2

0

Running docker inspect <container-id> listed the mount directory for the container. The mount directory resembled absolute path of my local computer. For example it was like /Users/<user-name>/dir/db-data. When I saw this I assumed this had to be in the local computer due to the prefix Users/<user-name> but this path was actually found in the root of the remote machine.

Vino
  • 2,111
  • 4
  • 22
  • 42
0

Thats because the directory for docker volumes is in the docker vm for MACOS. Where is /var/lib/docker on Mac/OS X

You would have to follow this to see the volume