version: '3' services: database: image: "postgres:alpine" # use latest official postgres version ports: - 5432:5432 # restart: always env_file: - database.env # configure postgres volumes: - database-data:/var/lib/postgresql/data/ # persist data even if container shuts down - ./setup/init.sql:/docker-entrypoint-initdb.d/init.sql volumes: database-data: # named volumes can be managed easier using docker-compose