2

I have a multiple container application, that is using the postgres image in docker-compose.yml file. Postgres container has volume on host machine for persistent storage.

When I run docker-compose up at first time all is fine, postgres creates db files in my host folder. After it I need to shut down application temporarily with docker-compose down if I'll change code of web container.

When I run docker-compose up second time, postgres overwriting all db files, but I need that data not changes. How can I solve this issue?

My docker-compose.yml

version: '2'

services:
    web:
      build: ./web
      command: python3 main.py
      volumes:
        - ./web:/app
      ports:
        - "80:80"  
      depends_on:
        - db
        - redis
      links:
        - db:db
        - redis:redis

    db:
      image: postgres
      ports:
        - "5432:5432"     
      environment:
        - POSTGRES_PASSWORD:0000
      volumes:
        - ./pgdb:/var/lib/postgresql/data

    redis:
      image: redis
      ports:
        - "6379:6379" 
      command: redis-server --appendonly yes  
      volumes:
        - ./redisdb:/data
2
  • I solve this problem. It occurs probably because I changed permissions for pgdb directory with host root user. By default I couldn't open pgdb in host machine because owner is postgres user. I could be wrong but after I stopped to change the resolution of the problem was gone. Commented Aug 28, 2016 at 7:28
  • Add an Answer to your own post so that you can close it. Others might be interested in this solution. Commented Aug 28, 2016 at 11:44

1 Answer 1

1

I solve this problem. It occurs probably because I changed permissions for pgdb directory with host root user. By default I couldn't open pgdb in host machine because owner is postgres user. I could be wrong but after I stopped to change the resolutions the problem was gone.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.