I understand that using an older version of docker-compose, we can create another container only with the data volume and associate it with volume_from to make it a βdata-only containerβ. However, I wanted to test the use of the new syntax.
version: '2' services: app: build: . links: - psql psql: image: postgres volumes_from: - psqldata ports: - "5432:5432" psqldata: image: postgres volumes: - psqlvolumes:/var/lib/postgresql/data/ volumes: psqlvolumes: driver: local
This was based on this post .
I have another script waiting for this postgres container to start before other containers start:
container: build: . volumes: - ./scripts/wait-for-postgres.sh:/code/wait-for-postgres.sh entrypoint: ./wait-for-postgres.sh "command"
with the script is as follows:
#!/bin/bash set -e export PGPASSWORD=postgres cmd=" $@ " until psql -h "postgres" -U "postgres" -c '\l'; do >&2 echo "Postgres is unavailable - sleeping" sleep 1 done >&2 echo "Postgres is up - executing command" exec $cmd
This was taken from the docker website.
This only causes the containers to stop and not fit at all, and I can't even get the postgres container to initialize with the tables I need.
source share