services: postgres: image: postgres:16-alpine container_name: postgres restart: unless-stopped environment: POSTGRES_USER: labuser POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: labdb POSTGRES_INITDB_ARGS: "--encoding=UTF8 --lc-collate=en_US.UTF-8 --lc-ctype=en_US.UTF-8" networks: - "net" ports: - "5432:5432" volumes: - postgres-data:/var/lib/postgresql/data deploy: resources: limits: cpus: '1.0' memory: 1G reservations: cpus: '0.5' memory: 512M healthcheck: test: ["CMD-SHELL", "pg_isready -U labuser -d labdb"] interval: 10s timeout: 5s retries: 5 # Объявляем volumes отдельно (bind-mount) volumes: postgres-data: driver: local driver_opts: type: none device: /mnt/postgres/postgres-data o: bind networks: net: external: true