How to compose an external data directory in PostgreSQL image within Docker? -


i'm trying create couple of containers docker. 1 postgres:latest image , other ubuntu:latest image postgresql-client installed.

i have existing database cluster in localhost i've used before install docker, of course. want use cluster in postgresql container. path in computer /users/marco/data.

i've created volume too, command docker volume create --opt device=/users/marco/data data_container store cluster in it.

then tried make docker-compose.ymlfile following content:

version: '2'  services:  db:   image: postgres   environment:   - pgdata=/var/lib/postgresql/data/   ports:   - "5432:5432"   volumes:   - data_container:/var/lib/postgresql/data/pgdata    shell:   image: ubuntu_pgsql   command: /bin/bash   tty: true   stdin_open: true    links:   - db  volumes:  data_container:   external: true  

when want launch containers docker-compose -d shows me following error:

error: db  cannot start service db: error while mounting volume    '/var/lib/docker/volumes/data_container/_data': error while mounting volume  options: type='' device='/users/marco/data' o='': no such device error: encountered errors while bringing project. 

what failing? thanks.

if data container directory should declare as:

volumes:   - ./data_container:/var/lib/postgresql/data/pgdata 

if used data_container without ./ before, docker compose understand file, not directory.


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -