Docker compose volumes don't save

I wrote this docker file for my project

version: "3,9"

services:
  postgres:
    container_name: ${POSTGRES_CONTAINER_NAME}
    image: ${POSTGRES_IMAGE}
    volumes:
      - ./storage/postgres:/var/lib/postgres/data
    env_file:
      - .env
    networks:
      - teratech-network

  minio:
    container_name: ${MINIO_CONTAINER_NAME}
    image: ${MINIO_IMAGE}
    env_file:
      - .env
    volumes:
      - /home/tony/Desktop/teratech\ services/storage/minio:/data/minio
    ports:
      - "9001:9001"
    networks:
      - teratech-network

  rabbitmq:
    container_name: ${RABBITMQ_CONTAINER_NAME}
    image: ${RABBITMQ_IMAGE}
    env_file:
      - .env
    networks:
      - teratech-network

  nginx:
    container_name: teratech-nginx
    image: nginx:stable-alpine3.17-slim
    volumes:
      - ./conf/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
    ports:
      - 80:80
    networks:
      - teratech-network

networks:
  teratech-network:

and this is my project tree:
my project
β”œβ”€β”€ conf
β”‚ └── nginx
β”‚ └── nginx.conf
β”œβ”€β”€ docker-compose.yaml
└── storage
β”œβ”€β”€ minio
└── postgres

but volumes don’t save.
how can I fix it?

It seems to work for everyone else, so it’s probably an issue with your configuration.

Which one does not work? How did you test? What error message did you receive?

there is no error and logs are normal
but when I create a bucket in minio, or create table and data to postgres, nothing save in volumes and after rerun, all of my data are losted
I tried both way( absolute path and relative path) but the problem didn’t solve

Usually this happens when you have an error in the volume binding.

Important Note: when mounting a volume to /var/lib/postgresql, the /var/lib/postgresql/data path is a local volume from the container runtime, thus data is not persisted on the mounted volume.

Source: doc

1 Like

Why would you expect that sharing a compose file would tell us anything, if we don’t know which images are used.

Every image is opinionated by the maintainer who creates it. They could use default paths, but choose to not do so.

you are right. sorry about that. I’m begginer in docker.
I’ll pay attention to this in future questions