viernes, 3 de noviembre de 2017

Docker Postgre persist data with volume: Error could not link file pg_xlog on windows 10 with toolbox


This is a problem that could happen if you try to mount a volume in this way:

https://stackoverflow.com/questions/45632593/postgres-docker-container-data-fails-to-mount-to-local

I solved this problem creating a volume :

docker volume créate  --name  paneek

and later only using it on my docker-compose.yml:

version: '2'
services:
 
  app:
    build:
      context: ./
      dockerfile: app.dockerfile
    working_dir: /var/www
    volumes:
      - ./:/var/www
    links:
      - pgsql   
 
  web:
    build:
      context: ./
      dockerfile: web.dockerfile
    working_dir: /var/www
    volumes_from:
      - app
    ports:
      - 80:80
    links:
      - app

  pgsql:
    image: "postgres:9.5"
    #to be available to use pgadmin
    ports:
      - 5432:5432
    environment:
      POSTGRES_USER: postgres
      POSTGRES_DB: postgres
      POSTGRES_PASSWORD: local
    volumes:
      - paneek:/var/lib/postgresql/data     
volumes:
  paneek:


Note: On Windows with toolbox there is not another way to do it.