Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local volume for redis in docker-compose #3

Closed
cnstntn-kndrtv opened this issue Dec 20, 2018 · 3 comments
Closed

local volume for redis in docker-compose #3

cnstntn-kndrtv opened this issue Dec 20, 2018 · 3 comments

Comments

@cnstntn-kndrtv
Copy link

cnstntn-kndrtv commented Dec 20, 2018

Is there any way to mount local volume for Redis data in docker-compose?
i have already tried this:

services:
  db:
    image: postgres
    restart: always
    ports:
      - 5432:5432
    volumes:
      - postgres-data:/var/lib/postgresql/data
volumes:
  postgres-data:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: ${PWD}/pgdata

and this:

services:
  db:
    image: postgres
     ...
    volumes:
      - ${PWD}/postgres-data:/var/lib/postgresql/data

and always get same error:

web_1     | django.db.utils.OperationalError: could not connect to server: Connection refused
web_1     | 	Is the server running on host "db" (172.25.0.3) and accepting
web_1     | 	TCP/IP connections on port 5432?

if i not specify path on host machine - it works. Like this:

services:
  db:
    image: postgres
     ...
    volumes:
      - postgres-data:/var/lib/postgresql/data
volumes:
  postgres-data:

But its not useful - Docker creates volumes somewhere in /var/lib/docker/volumes/modelchimp_postgres-data/_data (on Mac). It would be better to store all data in project folder.

@samzer
Copy link
Member

samzer commented Dec 20, 2018

Looking at the configuration above, you want to persist the data of Postgres instead of redis right?

@samzer
Copy link
Member

samzer commented Dec 20, 2018

@cnstntn-kndrtv
Just pushed in a commit that persists the postgres data in the local project folder. You can refer the below commit to see the changes I made to the docker file and added an additional script that helps modelchimp to startup when the local folder is used for docker postgres. You can pull the latest code and execute "bash docker.sh".
commit

You were pretty much on the right track. Following one works

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

Stack Overflow

@cnstntn-kndrtv
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants